Jump to content

Recommended Posts

	<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?

Link to comment
https://forums.phpfreaks.com/topic/98496-deletion-error/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504077
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504123
Share on other sites

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>"; 
}

Link to comment
https://forums.phpfreaks.com/topic/98496-deletion-error/#findComment-504144
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.