Hi people.. I just cant seem to figure out why this is not working..
Please take a look and let me know what you find wrong..
if ($insert){
for ($i=0;$i<$count;$i++) {
if($i_qty[$i]>0){
$query = "UPDATE $pr_it SET i_qty='$i_qty[$i]',i_extra='$i_extra[$i]',cal_diff='$cal_diff[$i]'WHERE p_id=$p_id AND i_id=$i_id";
$result = mysql_db_query("$db_name", $query);
}
}
I have this coming from a form array like:
$query_items = "SELECT * FROM $proposal_items WHERE p_id=$p_id";
$result_items = mysql_db_query("$db_name", $query_items);
while($row_items = mysql_fetch_array($result_items))
{
$i_id = $row_items['i_id'];
$i_qty = $row_items['i_qty'];
$i_extra = $row_items['i_extra'];
$cal_diff= $row_items['cal_diff'];
$query = "SELECT * FROM $items WHERE i_id=$i_id";
$result = mysql_db_query("$db_name", $query);
while($row = mysql_fetch_array($result))
{
$i_id = $row['i_id'];
$i_desc = $row['i_desc'];
$i_cost = $row['i_cost'];
?>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr valign="top">
<td width="6%">
<input type=text name=i_id[] value=<?="$i_id";?> ReadOnly=True size="5" tabindex="0" style="border: 0;">
</td>
<td width="74%">
<?="$i_desc";?>
</td>
<td width="10%" style="border-left-width:1px;" align="left">
<?="$i_cost";?>
</td>
<td width="20%" style="border-left-width:1px;" align="right" bgcolor="#ecedf0">
<table width="200" border="0" cellspacing="0" cellpadding="2">
<tr>
<td width="100" bgcolor="#ecedf0" valign="top">
<input type=text name=i_qty[] tabindex="<?="$count";?>" size="8" value="<?="$i_qty";?>">
</td>
<td width="50" bgcolor="#ecedf0" valign="top">
<input type=text name=i_extra[] tabindex="<?="$count";?>" size="7" value="<?="$i_extra";?>">
</td>
<td width="25" align="center" bgcolor="#ecedf0" valign="top">
<b>
<select name="cal_diff[]">
<option selected><?="$cal_diff";?></option>
<option>+</option>
<option>-</option>
</select>
</b></td>
</tr>
</table>
</td>
</tr>
</table>
<?
$count = $count + 1;
}
}
the form gets populated from select in while.
<input type="submit" name="Submit" value="Insert -> Continue">
<input type="hidden" name="insert" value="insert">
I need to insert changes made to the items.
Can Anyone help please..