Hi!
I have a script where I select a company name from a dropdown menu, an employee from another drop down menu, and a submit button. Upon submittal the combination I selected from the two dropdown menus appears in a table lower on the page.
All that works beautifully. the problem occurs when I added more functionality. I coded (and apparently incorrectly!) that when a name is selected, the 2nd script also displays the user's email address. What's happening is that the email address and password of the last selected name overrides everyone else, changing the email_addr and password column to the same variable. I am sure this is a simple oversight, but I cannot find the cause.
could someone take a peek at the code and see if they can spot what's causing my problem?
Much appreciated 🙂
Code:
$RELcpny_name=$HTTP_POST_VARS['RELcpny_name'];
$RELname=$HTTP_POST_VARS['RELname'];
$part_loc=$HTTP_POST_VARS['part_loc'];
$queery = "INSERT INTO dropdown1 VALUES('','". $_POST['RELcpny_name'] ."','". $_POST['RELname'] ."','". $_POST['part_loc'] ."')";
$queryresult = mysql_query($queery) or die(" Could not INSERT mysql query!");
$queery = "SELECT * from dropdown1";
$sqlquery = "SELECT id, RELcpny_name, RELname, part_loc FROM dropdown1 ORDER BY id";
$queryresult = mysql_query($sqlquery) or die(" Could not EXECUTE mysql query!");
$row = mysql_fetch_row($queryresult);
$id = $row[0];
$RELcpny_name = $row[1];
$RELname = $row[2];
$part_loc = $row[3];
$email_addr = $row[4];
$password = $row[5];
mysql_data_seek($queryresult,0) ;
while($row = mysql_fetch_array($queryresult)) {
$get_part_info = mysql_query("SELECT * FROM part_name WHERE name = '".$_POST['RELname']."'");
$row1=mysql_fetch_array($get_part_info);
$email_addr = $row1['email_addr'];
$password = $row1['password'];
if ($tdcount == 1) echo "<tr>";
echo '<td> '.$row['id'],'</td><td>'.$row['RELcpny_name'].'</td><td> '.$row['RELname'],'</td><td>'.$row['part_loc'],'</td><td>'.$row1['email_addr'],'</td><td> '.$row1['password'],'</td>';
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo '</tr>';
}