flforlife Posted April 23, 2008 Share Posted April 23, 2008 I know how to post multiple rows using a if and foreach loop. I can post multiple rows from one form. here is the form snippet..... <tr> <td><input name="entry[0][place]" type="text" /></td> <td><input name="entry[0][team]" type="text" /></td> <td><input name="entry[0][wl]" type="text" /></td> <td><input name="entry[0][gb]" type="text" /></td> <td><input name="entry[0][pcage]" type="text" /></td> <td><input name="entry[0][rs]" type="text" /></td> <td><input name="entry[0][ra]" type="text" /></td> <td><input name="entry[0][ags]" type="text" /></td> </tr> <tr> <td><input name="entry[1][place]" type="text" /></td> <td><input name="entry[1][team]" type="text" /></td> <td><input name="entry[1][wl]" type="text" /></td> <td><input name="entry[1][gb]" type="text" /></td> <td><input name="entry[1][pcage]" type="text" /></td> <td><input name="entry[1][rs]" type="text" /></td> <td><input name="entry[1][ra]" type="text" /></td> <td><input name="entry[1][ags]" type="text" /></td> </tr> <tr> <td><input name="entry[2][place]" type="text" /></td> <td><input name="entry[2][team]" type="text" /></td> <td><input name="entry[2][wl]" type="text" /></td> <td><input name="entry[2][gb]" type="text" /></td> <td><input name="entry[2][pcage]" type="text" /></td> <td><input name="entry[2][rs]" type="text" /></td> <td><input name="entry[2][ra]" type="text" /></td> <td><input name="entry[2][ags]" type="text" /></td> </tr> here is the code that post it as an array of data..... $mysql = mysql_connect($hostname, $username, $password); mysql_select_db($database); //? for php engine if (isset($_POST['btnSub'])) { //check for records later i $sql = "INSERT INTO major (place,team, wl, gb, pcage, rs, ra, ags) VALUES\n "; foreach ($_POST['entry'] as $data) { $dataArray[] = "('" . join ("','", $data) . "')"; } $sql .= join (",\n", $dataArray); /*echo '<pre>', $sql, '</pre>'; */ // view query mysql_query($sql) or die(mysql_error()); header("location:ft7tinput.html"); } How can I edit the form I tried this........ <tr> I did this so you know what I'm trying to target.... <td><input value="<?php echo $data[0] ?>" "name="entry[0][place]" type="text" /></td> Ok I tried to use the same if and foreach loop to edit the rows........... <td><input name="entry[0][team]" type="text" /></td> <td><input name="entry[0][wl]" type="text" /></td> <td><input name="entry[0][gb]" type="text" /></td> <td><input name="entry[0][pcage]" type="text" /></td> <td><input name="entry[0][rs]" type="text" /></td> <td><input name="entry[0][ra]" type="text" /></td> <td><input name="entry[0][ags]" type="text" /></td> </tr> <tr> <td><input name="entry[1][place]" type="text" /></td> <td><input name="entry[1][team]" type="text" /></td> <td><input name="entry[1][wl]" type="text" /></td> <td><input name="entry[1][gb]" type="text" /></td> <td><input name="entry[1][pcage]" type="text" /></td> <td><input name="entry[1][rs]" type="text" /></td> <td><input name="entry[1][ra]" type="text" /></td> <td><input name="entry[1][ags]" type="text" /></td> </tr> <tr> <td><input name="entry[2][place]" type="text" /></td> <td><input name="entry[2][team]" type="text" /></td> <td><input name="entry[2][wl]" type="text" /></td> <td><input name="entry[2][gb]" type="text" /></td> <td><input name="entry[2][pcage]" type="text" /></td> <td><input name="entry[2][rs]" type="text" /></td> <td><input name="entry[2][ra]" type="text" /></td> <td><input name="entry[2][ags]" type="text" /></td> </tr> Here is the edit code...... //? for php engine if (isset($_GET['btnSub'])) { //check for records later i $sql = "SELECT FROM major (place,team, wl, gb, pcage, rs, ra, ags) VALUES\n "; foreach ($_GET['entry'] as $data) { $dataArray[] = "('" . join ("','", $data) . "')"; } $sql .= join (",\n", $dataArray); /*echo '<pre>', $sql, '</pre>'; */ // view query mysql_query($sql) or die(mysql_error()); header("location:ft7tinput.html"); } When I try to look for the values to pop up it won't in the table. How do I edit rows using the same form? Link to comment https://forums.phpfreaks.com/topic/102531-edit-join-rows-using-a-formhelp/ Share on other sites More sharing options...
webent Posted April 23, 2008 Share Posted April 23, 2008 If I don't understand correctly and this reply is stupid, just ignore it... but if (isset($_GET['btnSub'])) ... shouldn't that be if (isset($_POST['btnSub'])) ... I mean you are posting from a form right, not getting from a url? The same for foreach ($_GET['entry'] as $data) to... foreach ($_POST['entry'] as $data) Link to comment https://forums.phpfreaks.com/topic/102531-edit-join-rows-using-a-formhelp/#findComment-524964 Share on other sites More sharing options...
flforlife Posted April 23, 2008 Author Share Posted April 23, 2008 I was trying to edit and update the query that I posted using the same form! I guess the foreach loop is not the answer. Link to comment https://forums.phpfreaks.com/topic/102531-edit-join-rows-using-a-formhelp/#findComment-524969 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.