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 Search this Thread Display Modes
  #1 (permalink)  
Old 2008-04-15, 06:24 AM
Junior Member
 
Join Date: Apr 2008
Posts: 7
flforlife is on a distinguished road
Default Insert multple records in a table pt2 !!!!

ok I have the code here input page......


<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>


this is add.php code....

foreach($_POST['sql']){

sql = $_POST["entry"][0] = array("place"=>"...", "team"=>"...");

sql = $_POST["entry"][1] = array("place"=>"...", "team"=>"...");
$result = mysql_query($sql);
}


I get an error message! Is it the foreach loop or should I use for loop?
Reply With Quote
  #2 (permalink)  
Old 2008-04-22, 09:28 PM
Senior Member
 
Join Date: Dec 2004
Posts: 199
strasm is an unknown quantity at this point
Default

Not sure exactly what you are trying to do but it would be more like this:

Code:
foreach($_GET[entry] as $entry){

 //access elements like this
 $team = $entry[team];



 //build sql and execute it here
 $sql = 'INSERT INTO table_name (team, place,...) VALUES ('. $team .', '. $place .',....)';
 $data = mysql_query($sql);
}
hope that helps
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 Search this Thread
Search this Thread:

Advanced Search
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 12:36 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.