Steve Angelis Posted March 29, 2008 Share Posted March 29, 2008 <p>Select a Member to Delete</p> <form action="index2.php?page=dptmbradd3" method="post"> <?php require('../inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); $dptid=$_POST['id']; ?> <input name="dptid" type="hidden" value="<?PHP echo $dptid; ?>"> <?PHP $result = mysql_query("SELECT id, mbr_name FROM mbr"); $result2 = mysql_query("SELECT * FROM departments_mbr"); $content=mysql_fetch_array($result2); echo "<select name='mbrid' size='1'>"; foreach ($content['dptm_dptid'] = $dptid) { while($row = mysql_fetch_array($result)) { echo "Update: <option name='" . $row["id"] . "' value='" . $row["id"] . "'>" . $row["mbr_name"] . "</option>"; } echo "</select>"; } ?> <input type=submit value="Delete"> </form> Here is the code. What I am trying to do is telling the code that where all the fields in the table with the 'dptm_dptid' field selected, which comes from a previous form page, and I know the id number is getting through, that to select all fields in the database where 'dptm_dptid' = the id from the previous page... but it does not work, it is still selecting all of the fields not just the ones I want. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/ Share on other sites More sharing options...
MadTechie Posted March 29, 2008 Share Posted March 29, 2008 $result = mysql_query("SELECT id, mbr_name FROM mbr WHERE id = $dptid"); Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504068 Share on other sites More sharing options...
Steve Angelis Posted March 29, 2008 Author Share Posted March 29, 2008 Wow... I feel so bloody stupid now, lol. To think I just did that on a differant page too thanx lol Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504069 Share on other sites More sharing options...
Steve Angelis Posted March 29, 2008 Author Share Posted March 29, 2008 Ok so I have modified the code but I am still baffled as to how to do it correctly. Here is what I have: <p>Select a Member to Delete</p> <form action="index2.php?page=dptmbrdel3" method="post"> <?php require('../inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); $dptid=$_POST['id']; ?> <input name="dptid" type="hidden" value="<?PHP echo $dptid; ?>"> <?PHP $result2 = mysql_query("SELECT * FROM departments_mbr where dptm_dptid='$dptid'"); $ughid = $content['dptm_userid']; echo "ughid=".$ughid; $result = mysql_query("SELECT id, mbr_name FROM mbr"); echo "<select name='mbrid' size='1'>"; while($row = mysql_fetch_array($result)) { echo "Update: <option name='" . $row["id"] . "' value='" . $row["id"] . "'>" . $row["mbr_name"] . "</option>"; } echo "</select>"; } ?> <input type=submit value="Delete"> </form> There are two tables, one called mbr which holds the member info, and departments_mbr which holds the id from both a previously aforementioned department and the member's id from all members int he department. This departments_mbr table connects the two allowing me to add multiple departments and as many members to each department as possible. From what i remember from school, this is called a master client client program. I cannot get it to show only members who are ONLY who match up with the correct dptm_dptid. The correct dptm_dptid shows up, but after that I am lost. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504077 Share on other sites More sharing options...
MadTechie Posted March 29, 2008 Share Posted March 29, 2008 okay i read this a few times.. and i'm still confused what your asking to do! it sounds like you want to do a join but without more infomation about the database its hard to say! Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504097 Share on other sites More sharing options...
Steve Angelis Posted March 29, 2008 Author Share Posted March 29, 2008 What I am doing is on the first page, selecting a department. The second page, here, selects all the members from THAT department, and the third deletes the selected member from the selected department. The problem is on the second page here where it only puts members who are in the selected department into the form. Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504123 Share on other sites More sharing options...
MadTechie Posted March 29, 2008 Share Posted March 29, 2008 So you want 1. to select a department. 2. to elect members from department (see 1) 3. Delete selected members try this <form action="index2.php?page=dptmbrdel3" method="post"> <?php require('../inc/config.php'); $linkid = @mysql_connect("$db_host", "$db_uname", "$db_pass"); mysql_select_db("$db_name", $linkid); $dptid=$_POST['id']; ?> <input name="dptid" type="hidden" value="<?PHP echo $dptid; ?>"> <?PHP $result = mysql_query("SELECT id, mbr_name FROM mbr WHERE ID in (SELECT dptm_userid FROM departments_mbr where dptm_dptid='$dptid')"); echo "<select name='mbrid' size='1'>"; while($row = mysql_fetch_array($result)) { echo "Update: <option name='" . $row["id"] . "' value='" . $row["id"] . "'>" . $row["mbr_name"] . "</option>"; } echo "</select>"; } Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504144 Share on other sites More sharing options...
Steve Angelis Posted March 29, 2008 Author Share Posted March 29, 2008 Yep that did it thanx Quote Link to comment https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504154 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.