brainonastick Posted October 15, 2007 Posted October 15, 2007 Hi there, I have a delete course button in a course and student page which passes to a delete record page. The data in the first page is displayed as follows using 2 "foreach" statements: Student 1 Remove this Student Course A Remove this Course Remove this Course Too Course B Remove this Course Remove this Course Too Course C Remove this Course Remove this Course Too Student 2 Remove this Student Course A Remove this Course Remove this Course Too Course B Remove this Course Remove this Course Too Course C Remove this Course Remove this Course Too etc. There are two different links I have been playing with. The first uses Course_ID and Usern_Name to identify the record for deletion. The variables get passed through the URL but the delete record does not happen. The second link is called Remove This Course Too and is based on -recid instead of Course_ID and User_Name but I cant get it to pass the recid to the next script. First Script <?php include_once('FX/FX.php'); include_once('FX/server_data.php'); $username_1 = $_POST['username']; $password_1 = $_POST['password']; $UN_Check=new FX($serverIP,$webCompanionPort,'FMPro7'); $UN_Check->SetDBData('Training_Account_Information.fp7','Training_Account_Information'); $UN_Check->SetDBPassword('fmsadmin','fmsadmin'); $UN_Check->AddDBParam('User_Name',$username_1, 'eq'); $UN_Check->AddDBParam('Password',$password_1, 'eq'); $UN_CheckResult=$UN_Check->FMFind(); $returnedCount=$UN_CheckResult['foundCount']; if($returnedCount == 0 ) { include 'login_account.php'; exit(); } $UN_CheckData = current($UN_CheckResult['data']); $Students=new FX($serverIP,$webCompanionPort,'FMPro7'); $Students->SetDBData('Training_Account_Information.fp7','Student_Information'); $Students->SetDBPassword('fmsadmin','fmsadmin'); $Students->AddDBParam('User_Name',$UN_CheckData['User_Name'][0], 'eq'); $StudentsResult=$Students->FMFind(); $returnedCount=$StudentsResult['foundCount']; $Courses=new FX($serverIP,$webCompanionPort,'FMPro7'); $Courses->SetDBData('Training_Account_Information.fp7','Selected_Courses'); $Courses->SetDBPassword('fmsadmin','fmsadmin'); $Courses->AddDBParam('User_Name',$UN_CheckData['User_Name'][0], 'eq'); $CoursesResult=$Courses->FMFind(); $returnedCount=$CoursesResult['foundCount']; ?> HTML etc <?php foreach($StudentsResult['data'] as $row) { ?> <?php echo $row['First_Name_1'][0]; ?> <?php echo $row['Last_Name_1'][0]; ?> Remove this Student <?php foreach($CoursesResult['data'] as $row2) { ?><?php echo $row2['Course_Name'][0]; ?> Remove this Course Remove this Course Too <?php } ?> <?php } ?> Second Script (note the commenting out of the recid code) <?php include_once('FX/FX.php'); include_once('FX/server_data.php'); $courseid = $_GET['courseid']; $username = $_GET['username']; /*$recid = $_GET['recid'];*/ $Search=new FX($serverIP,$webCompanionPort,'FMPro7'); $Search->SetDBData('Training_Account_Information.fp7','Selected_Courses'); $Search->SetDBPassword('fmsadmin','fmsadmin'); $Search->AddDBParam('Course_ID',$courseid, 'eq'); $Search->AddDBParam('User_Name',$username, 'eq'); /*$Search->AddDBParam('-recid',$recid, 'eq');*/ $SearchResult=$Search->FMDelete(true); /*print_r($SearchResult); exit(0);*/ include 'confirm_login.php'; ?> All advice gratefully received.
andygaunt Posted November 9, 2007 Posted November 9, 2007 Brainonastick, Is your code actually rendering the recid on the row? You could try adding the following to your foreach loop $RecordKeys=explode('.',$key); $recid=$RecordKeys[0]; Then you need to change your reference to your recid on Remove this Course Too to Remove this Course Too Any time you edit or delete a record you must pass the -recid. So try that and check the source on your page to make sure the recid is visible on your a href delete link. And don't forget to uncomment your lines: /*$recid = $_GET['recid'];*/ /*$Search->AddDBParam( '-recid',$recid, 'eq');*/
Recommended Posts
This topic is 6293 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now