phpretard Posted June 4, 2008 Share Posted June 4, 2008 Here is the source from the form I have poulated from a DB: <form method='post' action=''> <input type='hidden' name='id[0]' value='1'> <input type='text' size='40' name='Name[0]' value='Jena Bentley'><br> <input type='hidden' name='id[1]' value='2'> <input type='text' size='40' name='Name[1]' value='Kerri Koblentz'><br> <input type='hidden' name='id[2]' value='3'> <input type='text' size='40' name='Name[2]' value='Open'><br> <input type='hidden' name='id[3]' value='4'> <input type='text' size='40' name='Name[3]' value='Brandi Music'><br> <input type='hidden' name='id[4]' value='5'> <input type='text' size='40' name='Name[4]' value='Stacey Cundiff'><br> <input type='hidden' name='id[5]' value='6'> <input type='text' size='40' name='Name[5]' value='Open'><br> <input type='hidden' name='id[6]' value='7'> <input type='text' size='40' name='Name[6]' value='Larry Clark'><br> <input type='hidden' name='id[7]' value='8'> <input type='text' size='40' name='Name[7]' value='Chris Sarrett'><br> <input type='hidden' name='id[8]' value='9'> <input type='text' size='40' name='Name[8]' value='Buck McCreary'><br> <input type='hidden' name='id[9]' value='10'> <input type='text' size='40' name='Name[9]' value='Mark Gill'><br> <input type='hidden' name='id[10]' value='11'> <input type='text' size='40' name='Name[10]' value='Robbie Lampp'><br> <input type='hidden' name='id[11]' value='12'> <input type='text' size='40' name='Name[11]' value='Mitchel Martin'><br> <input type='submit' name='updatecoahes' value='submit'> </form> I know that somewhere somehow foreach smethin = something I should be able to update all this on one submit: if (isset($_POST['updatecoahes'])){ $Name=$_post['????'] $id_post['????'] foreach (???????) { $query = "UPDATE coaches SET Name='$Name[$i]' WHERE id='$id[$i]' LIMIT 1"; mysql_query($query) or die ('Error in query: $query'); } } [code] I have read the manual and none that I can tell applies? I found the guys tutorial on books and bookinfo No Worky. Any help here? [/code] Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/ Share on other sites More sharing options...
phpretard Posted June 4, 2008 Author Share Posted June 4, 2008 Not as easy as I thought? Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/#findComment-557183 Share on other sites More sharing options...
phpretard Posted June 4, 2008 Author Share Posted June 4, 2008 Question Not Clear? Nobody Likes me? Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/#findComment-557203 Share on other sites More sharing options...
phpretard Posted June 4, 2008 Author Share Posted June 4, 2008 Maybe this will help... if (isset($_POST['coachupdate'])){ $size = count($_POST['Name']); $i = 0; while ($i < $size) { $Name= $_POST['Name'][$i]; $id = $_POST['id'][$i]; echo $Name; /////////////I ADDED THIS TO DEBUG It just echos -- A $query = "UPDATE coaches SET Name = '$Name' WHERE id= '$id' LIMIT 1"; mysql_query($query) or die ("Error in query: $query"); ++$i; } Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/#findComment-557205 Share on other sites More sharing options...
haku Posted June 4, 2008 Share Posted June 4, 2008 for($i = 0; $i < count($_POST['name']); $i++ ) { $query = "UPDATE coaches SET Name='{$_POST['name'][$i]}' WHERE id='$_POST['id'][$i]' LIMIT 1"; mysql_query($query) or die ('Error in query: $query'); } I didn't really look too closely at your code, so this may not work, but try it out. Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/#findComment-557215 Share on other sites More sharing options...
phpretard Posted June 4, 2008 Author Share Posted June 4, 2008 Thank you for responding. <form method='post' action=''> <input type='hidden' name='id[0]' value='7' /> <tr> <td widht=25% align=right>Varsity: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[0]' value='Larry Clark' /></td> </tr> <input type='hidden' name='id[1]' value='8' /> <tr> <td widht=25% align=right>Junior Varsity: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[1]' value='Chris Sarrett' /></td> </tr> <input type='hidden' name='id[2]' value='9' /> <tr> <td widht=25% align=right>Super Midgets: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[2]' value='Buck McCreary' /></td> </tr> <input type='hidden' name='id[3]' value='10' /> <tr> <td widht=25% align=right>Midgets: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[3]' value='Mark Gill' /></td> </tr> <input type='hidden' name='id[4]' value='11' /> <tr> <td widht=25% align=right>Pee Wee: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[4]' value='Robbie Lampp' /></td> </tr> <input type='hidden' name='id[5]' value='12' /> <tr> <td widht=25% align=right>Mighty Mites: </td> <td width=75% align=left style='padding-left:10px'><input class=input type='text' name='Name[5]' value='Mitchel Martin' /></td> </tr> <tr> <td valign=bottom height=35 align=center colspan=2><input class=submit type='submit' name='coachupdate' value='Update Coaches' /></td> </tr> </form> Link to comment https://forums.phpfreaks.com/topic/108646-solved-this-should-be-easyplease-help-me-fill-in-the-blanks/#findComment-557225 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.