Search the Community
Showing results for tags 'multiple record'.
-
Hi, I have an html form that has 10 text field for trhe user too enter dates into. When the user clicks the submit button each text field should be added as a new record to a mysql table. The way I have it now if only 2 are filled in, rateher than making only 2 entries with the post data, it makes 20: the 2 that should be there and 8 empty ones, then repeats this, making 20. Can anyone offer assistance? Here is my code as it stands. <form class='form1' action='appointmentaddform.php' method='post' enctype='multipart/form-data' name='add_news-form' id='add_news_form'> <p><b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[0]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[1]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[2]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[3]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[4]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[5]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[6]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[7]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[8]' /><br /> <b><span class='text'>Date + Time<span></b> <input type=text size='50' name='adate[9]' /></p> <br /> <input type='submit' id='submit' name='submit' value='Add Appointments' /> <input type='hidden' value='new' /> </form> <?php include '../inc/connect.php'; if (isset($_POST['submit'])){ while(!empty($_REQUEST['adate'])){ foreach($_REQUEST['adate'] as $adate ){ mysql_query("INSERT INTO appointments VALUES ('', '$adate')"); } } } ?> Thanks
- 3 replies
-
- form
- multiple record
-
(and 1 more)
Tagged with: