live_ex3me Posted October 30, 2007 Share Posted October 30, 2007 hi there, i have this form, with 2 fields for each mysql result: while($row = mysql_fetch_array($res)){ print ' <input type=text name=order class=box size=5 value="'.$row['order'].'"> <input type=hidden name="id_mod" value="'.$row['id_mod'].'"> '; } saying that i have 3 sql results, i'll get from my form something like that: "?order=1&id_mod=2&order=2&id_mod=4&order=3&id_mod=5" . and evan if they would not have same name, how will i use them in a new sql request ? i've tryed something like this: <?php $names = ""; if (isset($_POST['fieldname'])) { $names = $_POST['fieldname']; } foreach ($names as $value ) { echo $value . "<br/>"; } ?> , but didn't work.. Link to comment https://forums.phpfreaks.com/topic/75341-solved-dynamic-form-issue/ Share on other sites More sharing options...
aschk Posted October 30, 2007 Share Posted October 30, 2007 If you are doing a GET request ?order=1&id_mod=2&order=2&id_mod=4&order=3&id_mod=5 then you need to make them arrays, e.g. ?order[]=1&id_mod[]=2&order[]=2&id_mod[]=4&order[]=3&id_mod[]=5 Then you can utilise them in PHP properly. To see what you're passing over : print_r($_GET['order]; print_r($_GET['id_mod']; Link to comment https://forums.phpfreaks.com/topic/75341-solved-dynamic-form-issue/#findComment-381030 Share on other sites More sharing options...
live_ex3me Posted October 30, 2007 Author Share Posted October 30, 2007 If you are doing a GET request ?order=1&id_mod=2&order=2&id_mod=4&order=3&id_mod=5 then you need to make them arrays, e.g. ?order[]=1&id_mod[]=2&order[]=2&id_mod[]=4&order[]=3&id_mod[]=5 Then you can utilise them in PHP properly. To see what you're passing over : print_r($_GET['order]; print_r($_GET['id_mod']; thanks.. i'll try it right now LE: i changed <input type=text [b]name=order [/b]class=box size=5 value="'.$row['order'].'"> <input type=hidden [b]name="id_mod"[/b] value="'.$row['id_mod'].'"> with <input type=text [b]name="order[]"[/b] class=box size=5 value="'.$row['order'].'"> <input type=hidden [b]name="id_mod[]"[/b] value="'.$row['id_mod'].'"> but now it looks like ?order%5B%5D=1&id_mod%5B%5D= ... if i use POST, the code ugave me would look different (exept post instead of get)? Link to comment https://forums.phpfreaks.com/topic/75341-solved-dynamic-form-issue/#findComment-381032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.