I have an update code which updates edited content. Everything updates except the sub_category_id.
Here is the code from the update_product_details:
<form action="update_do_product1.php" onSubmit="return validation(this);" name="frm">
<?php
$qry="select * from ".$dbprefix."product where product_id=".$_REQUEST['product_id'];
$q=$DB->doSQL($qry);
while($rs=mysql_fetch_array($q))
{
?>
<input name="old_product_name" type="hidden" class='text' value="<?=htmlspecialchars($rs["product_name"], ENT_QUOTES)?>" size="100" readonly="">
<tr><td class="tablehead" align="center" colspan="2">Edit Product</td></tr>
<tr><td width="16%" class="text">Product ID</td>
<td width="84%"><input name="product_id" type="text" class='text' value='<?=$rs["product_id"]?>' size="100" readonly=""></td></tr>
<tr><td width="16%" class="text">Product Name</td>
<td><input name="product_name" type="text" class='text' value="<?=htmlspecialchars($rs["product_name"], ENT_QUOTES)?>" size="100"></td></tr>
<tr><td width="16%" class="text">Key words</td>
<td><input name="keywords" type=text class='text' value='<?=nl2br(htmlspecialchars($rs["keywords"], ENT_QUOTES))?>' size="100" maxlength="100"></td></tr>
<tr><td width="16%" class="text">Price</td>
<td><input name="price" type=text class='text' value='<?=addslashes($rs["price"])?>' size="100"></td></tr>
<tr><td width="16%" class="text">Buy URL</td>
<td><input name="buyurl" type=text class='text' value='<?=$rs["buyurl"]?>' size="100"></td></tr>
<!--tr><td width="16%" class="text">Impression URL</td>
<td><input name="impressionurl" type=text class='text' value='<?=$rs["impressionurl"]?>' size="100"></td></tr-->
<tr><td width="16%" class="text">Image URL</td>
<td><input name="imageurl" type=text class='text' value='<?=$rs["imageurl"]?>' size="100"></td></tr>
<td class="text">Sub Category Name</td>
<td class="text"><select name="sub_category_id" class="text">
<option value=""><?=htmlspecialchars($rs["advertisecategory"], ENT_QUOTES)?></option>
<?php
//Populating Sub_Category Codes from gd_product Combo Box
$qry1="select sub_category_id,sub_category_name from ".$dbprefix."subcategory order by sub_category_name";
$res1=$DB->doSQL($qry1) or die(mysql_error().'-->'.$qry1);
while($row1=mysql_fetch_array($res1))
{
?>
<option value="<?=$row1['sub_category_id']?>"><?=$row1['sub_category_name']?></option>
<?
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" class="text">
Description:<br/>
<?php
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->BasePath = 'fckeditor/';
$oFCKeditor->Value = stripslashes(nl2br($rs["description"]));
$oFCKeditor->Height = '300';
$oFCKeditor->Create() ;
?>
</td>
</tr>
<?php
}
?>
<tr><td align="center" colspan="2" class="text"><input type="submit" name="submit" value="Submit" class="but"></td>
</tr>
</table>
</form>
Here is the code from the update_do_product1 page:
<?
$id=$REQUEST['product_id'];
$product_id=addslashes($REQUEST['product_id']);
$product_name=addslashes($REQUEST['product_name']);
$keywords=addslashes($REQUEST['keywords']);
$description=addslashes($REQUEST['description']);
$description=nl2br($description);
$price=addslashes($REQUEST['price']);
$buyurl=addslashes($REQUEST['buyurl']);
$impressionurl=addslashes($REQUEST['impressionurl']);
$imageurl=addslashes($REQUEST['imageurl']);
$advertisecategory=addslashes($REQUEST['advertisecategory']);
$sel_prev="select product_id,product_name from ".$dbprefix."product where product_id={$product_id}";
if($exe=$DB->doSQL($sel_prev))// or die(mysql_error()."-->".$sel_prodname);
$fetch=mysql_fetch_array($exe);
else
echo mysql_error()."-->".$sel_prev;
$product_id_old=$fetch["product_id"];
$product_name_old=$fetch["product_name"];
if($DB->isopen)
{
$qo=$DB->doSQL("select * from ".$dbprefix."product");
if(strtoupper($_REQUEST['old_product_name'])!=strtoupper($_REQUEST['product_name']))
{
while($qo_rs=mysql_fetch_array($qo))
{
if(strtoupper($qo_rs['product_name'])==strtoupper($_REQUEST['product_name']))
{
header("location:update_product_details1.php?product_id=$id&flag=1");
}
}
}
$up_q="UPDATE ".$dbprefix."product SET product_name = '".$product_name."',
keywords = '{$keywords}',
description = '{$description}',
price = {$price},
buyurl = '{$buyurl}',
impressionurl = '{$impressionurl}',
imageurl = '{$imageurl}',advertisecategory='{$advertisecategory}'
WHERE product_id = {$product_id}";
$rs=$DB->doSQL($up_q);
if($rs)
{
echo '<tr><td class="tablehead" align="center">Message Box</td></tr>';
echo "<tr><td align='center' class='text'>Successfully Updated<br></td></tr>";
echo "<tr><td align='center' class='text'><a href='index.php' title='click here to go to Home Page' class='link'>Go To Home</a></td></tr>";
}
else
echo "<td class='text'>Not updated Try Again</td>";
}
else
{
echo "Data Base Connection Could Not Established";
}
?>
</table>
Can anyone tell me what I am missing to update the sub_category_id?
Thanks,
phpnovice123