Jump to content

help with this insert code?


kevgais

Recommended Posts

hi,

 

I have this sql statement on form.php, thanks to this forum. I want to amend it but am having trouble understanding it. The form prior to this creates 2 empty textboxes on the fly.

 

I need to insert the same random number into the 'id' field next to every record inserted in the below statement.

 

Any ideas?

 

Code:

 

$sql.="INSERT INTO guests (guest_name, guest_email, event_id) VALUES";

for($i=0;$i<sizeof($_POST['username']);$i++){

 

$sql.="('".mysql_real_escape_string($_POST['username'][$i])."','".mysql_real_escape_string($_POST['email'][$i])."','".mysql_real_escape_string($_POST['id'][$i)."')";

if(!$i==sizeof($_POST['username'])){

$sql.=",";

}

}

Link to comment
https://forums.phpfreaks.com/topic/106810-help-with-this-insert-code/
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.