Demonic Posted February 25, 2007 Share Posted February 25, 2007 Alright I've gotten multiple form names with the same name but i don't know how to give the select a special ID so I can update the current ID for each row <form method="post" action="index.php"> <select name="cat[]"> <option value="1" selected="selected">1</option> <option value="2">2</option> </select> <select name="cat[]"> <option value="1">1</option> <option value="2" selected="selected">2</option> </select> </form> well when i do a check it selects current order for each row but tthe form doesn't have an unique id for each selection box. Can i do: <form method="post" action="index.php"> <select name="cat[1]"> <option value="1" selected="selected">1</option> <option value="2">2</option> </select> <select name="cat[2]"> <option value="1">1</option> <option value="2" selected="selected">2</option> </select> </form> cat[x] x being the row # If so how can I update that so it updates each row. I was thinking $num = mysql_total_rows($tablename); for($i=0;$i <= $num;$i++){ $catid = $_POST['cat[$i]']; foreach($_POST['cat'] as $catord){ mysql_query("UPDATE `order` SET order id='$catord' WHERE id='$catid' "); }} But i doubt that would even work. Any suggestions on how to do this differently or how I can actually make this work? Link to comment https://forums.phpfreaks.com/topic/40047-is-there-a-way/ Share on other sites More sharing options...
nloding Posted February 25, 2007 Share Posted February 25, 2007 Not sure where you're headed with the MySQL part, but as for the unique ID's ... what you're trying to do there isn't going to work. You'll have to use cat1[] and cat2[] and so on. Link to comment https://forums.phpfreaks.com/topic/40047-is-there-a-way/#findComment-193707 Share on other sites More sharing options...
Demonic Posted February 25, 2007 Author Share Posted February 25, 2007 I might have to just do a for statement. $total = mysql_num_rows($sqlquery); for($i=1;$i <=$total;$i++){ $id = explode("cat",$_POST[cat$i]); mysql_query("UPDATE order SET order='$_POST[cat$i]' WHERE id='$id' ") or die(mysql_error()); } You think that will work? wait I don't need $id part since it wont work i would just need $i wouldn't I? humm. I'm going to try it. Link to comment https://forums.phpfreaks.com/topic/40047-is-there-a-way/#findComment-193782 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.