Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

Can someone please help with this code

General discussions related to php

Moderators: macek, egami, gesf

Can someone please help with this code

Postby Jacques » Thu Nov 21, 2002 9:59 am

I am trying to do a multiple insert.

$sdcount=10;
for ($i=0;$i<$stdcount;$i++){
$query = "Insert into $mysql_cat (id, user, category) values ('', '$user','$category[$i]')";
$result = mysql_query($query) or die("ERROR: cannot INSERT data into database");
}
// for ($i = 0; $i < $stdcount; $i ++)
?>
<form method=post>
<input type="text" name="category[]">
<input type="text" name="category[]">
<input type=hidden name=sdcount value=$sdcount>
<input type="submit" value="Upload/Submit">
</form>
Jacques
New php-forum User
New php-forum User
 
Posts: 10
Joined: Fri Oct 18, 2002 8:07 am

Re: Can someone please help with this code

Postby Oleg Butuzov » Thu Nov 21, 2002 8:27 pm

I am trying to do a multiple insert.

<?
echo "
<form method=post>
<input type=hidden name=form value=0>";

for ($i=0;$i<$stdcount;$i++){
echo "<input type=text name=category[$i]><br>\n";
}
echo "<input type=hidden name=sdcount value=$sdcount>
<input type=submit value=Upload/Submit>
</form>";

if (isset($form)){
$sdcount=10;
for ($i=0;$i<$stdcount;$i++){

$query = "Insert into $mysql_cat (id, user, category) values ('', '$user','$category[$i]')";
$result = mysql_query($query) or die("ERROR: cannot INSERT data into database");
}
}
// for ($i = 0; $i < $stdcount; $i ++)
?>
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to PHP General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.