mysql - php update not working -
i trying change form data , updating data in mysql. data not changing when ever trying update. form page below:
while ($list5 = mysql_fetch_array($result)) { $reqitem=$list5['id']; echo "<td width='34%' id='addinput'><input type='text' size='70' id='item_name$i' name='item_name[$i]' placeholder='{$list5['prod_description']}' value='{$list5['prod_description']}'></td>"; }
and save page script follows:
foreach($_post['id'] $key=>$value) { $item_name= $_post['item_name'][$i]; $q = "update poto_customer_items prod_description='$item_name' tender_id='$tender_id' , id='$value' "; mysql_query($q) or die(mysql_error()); }
i know there problem script. new php not able grasp making mistake. can please me on this.
following html code:
<html> <head> <title></title> </head> <body> <h3> </h3> <form action='generate_quot_cust_edititems_save_1.php?tender_id=1400692' class='single' id="cart" method='post' name='cart'> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>154<input id='item_name0' name='item_name[0]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>155<input id='item_name1' name='item_name[1]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>156<input id='item_name2' name='item_name[2]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>157<input id='item_name3' name='item_name[3]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style="border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>158<input id='item_name4' name='item_name[4]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>159<input id='item_name5' name='item_name[5]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div> <div class="base"> <div align="left"> <table border="1" cellpadding="3" cellspacing="3" style= "border-collapse: collapse;" width="100%"> <tr> <td id='addinput' width='34%'>160<input id='item_name6' name='item_name[6]' placeholder='packing charges.' size='70' type='text' value='packing charges.'></td> </tr> </table> </div> </div><br> <input type='submit' value='--update data--' id='continue'/> </form> </body> </html>
the following bit in save.php
looks fishy:
foreach($_post['id'] $key=>$value) { //$item_name= $_post['item_name'][$i]; $q = "update poto_customer_items set prod_description='$value' tender_id='$tender_id' , id='$key' "; mysql_query($q) or die(mysql_error()); }
shouldn't looping on $_post['item_name']
? like:
foreach($_post['item_name'] $key=>$value) { $item_name= $_post['item_name'][$i]; $q = "update poto_customer_items set prod_description='$value' tender_id='$tender_id' , id='$key' "; mysql_query($q) or die(mysql_error()); }
if that's case might consider change form page logic follows:
while ($list5 = mysql_fetch_array($result)) { $reqitem=$list5['id']; echo "<td width='34%' id='addinput'><input type='text' size='70' id='item_name$i' name='item_name[$reqitem]' placeholder='{$list5['prod_description']}' value='{$list5['prod_description']}'></td>"; }
Comments
Post a Comment