gerkintrigg Posted July 28, 2006 Share Posted July 28, 2006 Hiya.I'm making a shopping cart system with admin back end to change categories. I'm trying to allow multiple categories to be ammended at the same time using a loop like this:[code]$cat_sql=mysql_query("SELECT category FROM Categories ORDER BY category"); while ($cat_loop=mysql_fetch_array($cat_sql)){ echo '<tr bgcolor="#FFFFFF"> <td width="133" class="text" valign="top"><a href="index.php?mcat='.$cat_loop['category'].'">'.$cat_loop['category'].'</a><br> </td> <td width="12"> </td> <td width="145" valign="top"><input name="'.$cat_loop['id'].'" type="text" class="search" value="'.$cat_loop['category'].'"> <input name="id" type="hidden" id="mcat" value="'.$cat_loop['id'].'"> </td> </tr>'; }[/code]My question is, once submitted, how do I loop through all these fields and update each one? I understand the SQL and I think the PHP is something like foreach($_POST[]){ but that's clearly not right.Could anyone help me please? Quote Link to comment Share on other sites More sharing options...
hackerkts Posted July 28, 2006 Share Posted July 28, 2006 If you want to get informations from the form submited, use $_POST['[b]form-name[/b]'].Example:[code]<input name="'.$cat_loop['id'].'" type="text" class="search" value="'.$cat_loop['category'].'">[/code]Change it to something like<input name="search" type="text" class="search" value="'.$cat_loop['category'].'">So it will be $_POST['search'] hope this is what you looking for. Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted August 2, 2006 Author Share Posted August 2, 2006 No, I need to loop through posts, not retrieve hard-coded posted field names, but thanks anyway. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 2, 2006 Share Posted August 2, 2006 foreach($_POST[$cat_loop] AS $val =>$key){ } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.