Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Programming Help > PHP Programming Help

PHP Programming Help Post any question relating to PHP Programming here and hopefully someone can help.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2008-04-23, 05:40 PM
Junior Member
 
Join Date: Apr 2008
Posts: 7
flforlife is on a distinguished road
Default Edit join rows using same form!!!!!Help!!!!

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.....
Code:
<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.....
Code:
$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........
Code:
<tr>
I did this so you know what I'm trying to target....
Code:
<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...........
Code:
<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......
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?
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.0 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.0 (a popular PHP IDE) and NuCoder 1.4 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:19 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.