kevgais Posted May 22, 2008 Share Posted May 22, 2008 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.=","; } } Quote Link to comment https://forums.phpfreaks.com/topic/106810-help-with-this-insert-code/ Share on other sites More sharing options...
fenway Posted May 23, 2008 Share Posted May 23, 2008 LAST_INSERT_ID()? Quote Link to comment https://forums.phpfreaks.com/topic/106810-help-with-this-insert-code/#findComment-548154 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.