rockindano30 Posted May 12, 2008 Share Posted May 12, 2008 Good morning every one, well i solved one problem but came across another one. just when i thought i had it all working fine, noticed something else. i'm working on a app. and i have three tables, employees, departments, and emp_keys, well I had the problem to get the correct emp_id (primary key from employees) to be pass and delete that record. well i figured that one out. now my table has over 30 employees, it passes the key able to delete but only up to emp_key 9 once it gets to 10 it starts again at 1. don't know if i am making sense or not but here is some of my code: $emp_id=$_GET["emp_id"]; $search=$_POST["search"]; $search2=$_POST["search2"]; $search= trim($search); $search2= trim($search2); if(!isset($search) || empty($search) || !isset($search2) || empty($search2)) { print"<p>Your search was not sucessfull due for one of the followings:<br />"; print "Make sure that you have the first and last name filled.<br />"; print "Make sure that you spelled the employee's name currectly.<br />"; print "Or there are no keys asigned to that employee.</p>"; } else{ $search=addslashes($search); $search2=addslashes($search2); //get the mysql and store them in $result $query = "select employees.emp_id,Fname,Lname, email, dept, group_concat(key_num separator ' - ') as key_num, group_concat(accss separator ' - ') as accss FROM departments, employees, emp_keys where Fname like '%$search%' and Lname like '$search2' and departments.dept_id= employees.dept_id and emp_keys.emp_id=employees.emp_id group by employees.emp_id"; $result = mysql_query($query); $num_result = mysql_num_rows($result); if ($num_result < 1) print "<p>No employee found by that name.<br />Please make sure that you typed in the employee's name correctly.<br />Or there is no keys asigned to that employee.</p>"; else { //grab all the content while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; $dept=$r["dept"]; $Fname=$r["Fname"]; $Lname=$r["Lname"]; $email=$r["email"]; $key_num=$r["key_num"]; $accss=$r["accss"]; $emp_id=$r["emp_id"]; ?> <p style="padding:0px; text-decoration:underline">Your Search Results are below:</p><br /> <table width="100%" border="0" cellpadding="1" cellspacing="0" class="table1"> <tr><td width="20%"><strong>Department:</strong></td> <td width="80%"><font face="Arial, Helvetica, sans-serif"><?php print $dept; ?></font></td> </tr> <tr><td width="20%"><strong>Name:</strong></td> <td width="80%"><font face="Arial, Helvetica, sans-serif" style="color:#CC6600"><?php print $Fname." ".$Lname; ?></font></td> </tr> <tr><td width="20%"><strong>Email:</strong></td> <td width="80%"><font face="Arial, Helvetica, sans-serif"><?php print $email; ?></font></td> </tr> <tr><td width="20%"><strong>Key #:</strong></td> <td width="80%"><font face="Arial, Helvetica, sans-serif"><?php print $key_num; ?></font></td> </tr> <tr><td width="20%"><strong>Key Access:</strong></td> <td width="80%"><font face="Arial, Helvetica, sans-serif"><?php print $accss; ?></font></td> </tr> <tr><td width="20%"> <?php //here it print the correct emp_id print $emp_id; ?> </td> <td width="80%"> <?php ///but here once it gets to emp_id 9 it starts all over again at 1. print"<a href=\"delete.php?emp_id={$emp_id['emp_id']}\">Remove"; ?> </td> </tr> </table> <?php }//end while loop } } ?> see code for comments. Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/ Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 k another thing that i noticed is that its also not printing all the records only half of them Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539035 Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 hello anyone???? Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539045 Share on other sites More sharing options...
BlueSkyIS Posted May 12, 2008 Share Posted May 12, 2008 $emp_id is not an array, so $emp_id['emp_id'] is invalid syntax. Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539052 Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 yes it is its getting context of emp_id into $emp_id in this line of code $emp_id=$r["emp_id"]; but i think the problem is with the query select syntax, but i can't see where. Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539054 Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 it has to be with the query select line cause it doesn't go through all the table only half way. please please someone help Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539058 Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 man no help here. Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539074 Share on other sites More sharing options...
revraz Posted May 12, 2008 Share Posted May 12, 2008 Maybe you should read the guidelines about bumping your posts. Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539081 Share on other sites More sharing options...
rockindano30 Posted May 12, 2008 Author Share Posted May 12, 2008 about what Link to comment https://forums.phpfreaks.com/topic/105268-solved-help-with-deleting-records/#findComment-539085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.