Jump to content

Edit multple rows using the same form.


flforlife

Recommended Posts

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 multiple rows using the same form?

 

Link to comment
https://forums.phpfreaks.com/topic/102577-edit-multple-rows-using-the-same-form/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.