Variables : writing to DB issues
Posted: Thu Nov 24, 2005 2:05 am
Hi All,
I'm having some trouble writing a value to my DB.
Can anyone see any issues with it?
It's writing the $id to the DB instead of $complaintType (SQL Insert code below.)
I've looked and played with this for hours and can't work it out.
TIA, wil
-- insert Code --
I'm having some trouble writing a value to my DB.
Can anyone see any issues with it?
It's writing the $id to the DB instead of $complaintType (SQL Insert code below.)
I've looked and played with this for hours and can't work it out.
TIA, wil
Code: Select all
<?
$productServiceList = array();
$sql_query = mysql_query("SELECT * FROM complaintType ORDER BY complaintType");
echo "<select name=\"complaintType\" onchange=\"showProdServ(this.options[this.selectedIndex].value)\">
<option value=\"\">-- Please Select --</option>\n";
while(list($complaintType, $id, $productService)=mysql_fetch_row($sql_query))
{
echo "<option value=\"$id\">$complaintType</option>\n";
$productServiceList[$id] = $productService;
}
echo "</select>
<span style=\"font-weight:bold;\" id=\"prodServ\"></span>
<script>
Viewer = document.getElementById(\"prodServ\");
ProdServList = new Array();";
foreach ($productServiceList as $id=>$prodServ)
echo "ProdServList[{$id}] = \"{$prodServ}\"\n";
//echo $productServiceList;
echo "
function showProdServ(val) {
Viewer.innerHTML = ProdServList[val];
if (ProdServList[val] == 'Product') {
showdiv();
}
else {
hidediv();
}
}
</script>";
?>Code: Select all
$result = mysql_query("INSERT INTO complaint(complaintType, detail, complaintNumber)
VALUES ('$complaintType', '$otherDetail', '$complaintNumber')");