Forum Moderators: coopster
i have a page on a scheduling system that i'm creating that i need to insert several records on the same table. to make it easy on the data entry person i would like to insert these records all at the same time. is there a way to do this in PHP?
for example: you have a single day that can have multiple entries (available times).
thanks in advance
Example(HTML form):
<form action="insert_script.php">
<input type="text" name="name[]" />
<input type="text" name="date[]" />
<input type="text" name="time[]" />
<input type="submit" />
</form>
Example(insert_script.php):
<?php
for( $i=0; $i < count($name); $i++)
{
if ($name[$i] == "") continue;
sql .= "INSERT INTO tablename ( `name` , date` , `time`) VALUES ('$name[$i]', '$date[$i]', '$time[$i]')";
}mysql_query($sql) or die ("Something went wrong!");
?>
Play around with that and you should figure it out.
e.g. -
8:30AM - variable (0 - 3)
9:00AM - variable (0 - 3)
etc...
the variable is to select a status value (0 - 3) presented in a list/menu, so would i just name each list menu down the page, 'time1','time2', 'time3', etc? and then the loop in the script would pick that up or would i name each one just 'time'?