rockindano30 Posted May 9, 2008 Share Posted May 9, 2008 Can someone help me figure this out??? please Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/ Share on other sites More sharing options...
NorthWestSimulations Posted May 9, 2008 Share Posted May 9, 2008 umm... Help you figure What out? Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537025 Share on other sites More sharing options...
DeanWhitehouse Posted May 9, 2008 Share Posted May 9, 2008 figure what out? beat me to it Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537026 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 its from a previous post i did Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537027 Share on other sites More sharing options...
DarkWater Posted May 9, 2008 Share Posted May 9, 2008 That doesn't help at all. Please DON'T SPAM A HELP FORUM. Wow. =/ Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537031 Share on other sites More sharing options...
Cory94bailly Posted May 9, 2008 Share Posted May 9, 2008 A link to the post might help a tiny bit..? And please don't post more than once on the same topic. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537033 Share on other sites More sharing options...
DeanWhitehouse Posted May 9, 2008 Share Posted May 9, 2008 post a questions, or don't post Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537034 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 chill chill question is up. and its a good one Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537035 Share on other sites More sharing options...
Cory94bailly Posted May 9, 2008 Share Posted May 9, 2008 chill chill question is up. and its a good one GIVE US A FREAKING LINK... Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537036 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 I JUST POSTED MY QUESTION Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537039 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 Hello all, Well I'm trying to get my script to work and I'm stuck and can't get around it or figure it out. I have three tables. employees(emp_id, Fname, Lname, email, dept_id) //emp_id is pk and dept_id is fk departments(dept_id,deptname,phone) // dept_id pk emp_keys (kid,emp_id, access, key_num) //kid is pk emp_id is fk now i want to delete an employee from employees and also delete their key(s) from key table. this is my code in my search page. Code: <?php $search=addslashes($search); $search2=addslashes($search2); //get the mysql and store them in $result $query = "select 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%"> </td> <td width="80%"> <?php print"<a href='delete.php?emp_id={$emp_id['emp_id']}'>Remove</a><br />";?></td> </tr> </table> <?php }//end while loop } } ?> this is my code in my delete.php page Code: <?php ///bla bla bla connect to bd..... //select which database you want to edit mysql_select_db("bldg_keys"); $emp_id = $_GET[emp_id]; $dept_id=$_GET[dept_id]; $query = "DELETE Fname,Lname,email,dept,key_num,accss FROM emp_keys, departments, employees WHERE departments.dept_id=employees.dept_id and emp_keys.emp_id=employees.emp_id"; // $query = "DELETE FROM employees WHERE emp_id=$empid"; $result = mysql_query($query) or die ("Error in query: $query.".mysql_error()); print "<p>Employee has been removed permanently from our database.<br />"; print "Click <a href=\"index.php\">HERE</a> to go to home page.</p>"; ?> im trying to pass the emp_id from search.php page to delete. but i'm stuck cause it is not getting the emp_id. can anybody see whats wrong here? i can't. and this is the error i get in my delete.php page Error in query: DELETE Fname,Lname,email,dept,key_num,accss FROM emp_keys, departments, employees WHERE departments.dept_id=employees.dept_id and emp_keys.emp_id=employees.emp_id.Unknown table 'fname' in MULTI DELETE Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537042 Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 All I know is with databases you want to be safe. and its safer to run several deletes instead of trying to delete everything at once. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537046 Share on other sites More sharing options...
BlueSkyIS Posted May 9, 2008 Share Posted May 9, 2008 should be DELETE tablename1.fieldname1, tablename1.fieldname2 FROM table list... MySQL thinks Fname is a table name instead of a field name. prepend the table name. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537048 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 well on my search.php page i am trying to pass the emp_id through a link to remove but no emp_id is being passed any suggestions there Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537052 Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 How are you passing it? If you are passing it through the browser you might need to put: $eid = isset($_REQUEST['emp_id']) ? $_REQUEST['emp_id'] : ''; above all your code to retrieve the emp_id... if you are doing it through a form field, $eid = $_POST['emp_id']; should work fine. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537055 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 im passing in through a link here the code $search=addslashes($search); $search2=addslashes($search2); //get the mysql and store them in $result $query = "select 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%"> </td> <td width="80%"> //////////************IN THIS LINE HERE BUT NO ID IS BEING RETRIVE OR PASS.************* <?php print"<a href='delete.php?emp_id={$emp_id['emp_id']}'>Remove</a><br />";?></td> </tr> </table> Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537057 Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 In the link are you getting the emp_id? Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537061 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 well trying too but does not get it. it used to when i was using a flat db. but once i spread all my tables the way they should be the link wasn't working any more. there is no emp_id being pass. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537064 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 where did everyone go? ??? Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537083 Share on other sites More sharing options...
DarkWater Posted May 9, 2008 Share Posted May 9, 2008 Changing the DB wouldn't really change the $emp_id. =/ Make sure it's on the other page and check how you're sending it. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537085 Share on other sites More sharing options...
rockindano30 Posted May 9, 2008 Author Share Posted May 9, 2008 but i also changed the query line when querying from db. i didn't change anything else in my code. Link to comment https://forums.phpfreaks.com/topic/104921-can-some-one-help-me/#findComment-537086 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.