Guys please help me with this one... It's giving me a headache already...![]()
The script is about editing requirements. We have leads and leads have one or more requirements. I have a script that is supposedly can edit the requirement. The user must be able to add the quantity of the existing requirement and the user can also add a new requirement.
here's a bit of script from the form:
And then here's the script that processes the one above:PHP Code:<?
$h_id = 0;
$get_hardware = mysql_query("select * from tbl_products where category='hardware'");
?>
<table border="0" cellspacing="0" cellpadding="0">
<?
while($hardware = mysql_fetch_array($get_hardware)){
$prod_id = $hardware["id"];
$prod = $hardware["name"];
$hwreq = mysql_query("select requirement, qty from tbl_requirements where id='$id' and requirement='$prod_id'");
$hr=mysql_fetch_row($hwreq);
if($prod_id==$hr["0"]){
echo"<tr>
<th align=\"left\" width=\"60%\"><input name=\"hreq[]\" type=\"checkbox\" value=\"$prod_id\" checked />".$prod." </th>
<td><input type=\"text\" name=\"hw[]\" id=\"$h_id\" size=\"6\" value=\"".$hr["1"]."\" OnChange=\"checMySwBox(this.id)\"></td>
</tr>";
$h_id++;
}
else{
echo"<tr>
<th align=\"left\" width=\"60%\"><input name=\"hreq[]\" type=\"checkbox\" value=\"$prod_id\" />".$prod." </th>
<td><input type=\"text\" name=\"hw[]\" id=\"$h_id\" size=\"6\" OnChange=\"checMySwBox(this.id)\"></td>
</tr>";
$h_id++;
}
}
?>
</table>
Basically, before the if statement, I have a query that deletes the previous requirements of the lead. So the idea is to delete the old requirements, and then add the new ones.PHP Code:$hw = $_REQUEST['hw'];
$hreq = $_REQUEST['hreq'];
if(count($hreq)>0){
for($i=0; $i<count($hreq); $i++){
$addhreq = mysql_query("insert into tbl_requirements values('$id','".$hreq[$i]."','".$hw[$i]."')");
echo "count=".count($hreq)." prod-".$hreq[$i]." qty=".$hw[$i];
}
}
The problem now is that everytime I run the script, the arrayed textboxes is not working, I mean they all return 0, i don't know what's the problem... can anyone help me please???!!
Thanks in advance!



Bookmarks