G’day,
I’m having a problem getting the right value to post on a form I’ve made. It is passing the ID but not the name.
Here’s my code:
<td name="tech_userlogin" id="tech_userlogin" align="right" valign="top"><select name="tech_userlogin" id="tech_userlogin" class="db_field_name">
<?php
$sql="SELECT techID, tech_userlogin FROM technicians";
$result=mysql_query($sql);
$options="";
while ($row=mysql_fetch_array($result)) {
$techID=$row["techID"];
$tech_userlogin=$row["tech_userlogin"];
$options.="<OPTION VALUE=\"$techID\">$tech_userlogin</option>";
}
?>
<OPTION VALUE="">---Select---
<?php echo $options; ?>
</SELECT>
The form posts to this page:
<?php
include 'sql_connect_R.inc.php';
$id = mysql_real_escape_string($_POST['jobID']);
$equip = mysql_real_escape_string($_POST['wo_equip']);
$techID = mysql_real_escape_string($_POST['techID']);
$tech_login = mysql_real_escape_string($_POST['tech_userlogin']);
mysql_query("UPDATE work_orders SET wo_equip = UCASE('$equip'), wo_techID = '$techID', tech_userlogin = '$tech_login'
WHERE jobID = '$id'");
mysql_close($con);
I’m very new to PHP/MySQL and it took me a couple of days to get something that would put the tech_userlogin into a dropdown box. That is working, but when it posts the techID comes through on both $techID and $tech_userlogin.
Could someone please help me sort this out? Any help would be greatly appreciated.
Cheers, Spud
What seems to be happening is that you’ve named the select box “tech_userlogin”, but in the option tags the value is set to the techid. Since the value is what’s sent back in the $_REQUEST array, try something like this instead:
I believe that will give you what you want.