I have a table above this and on each row are inputs named with the names you see in the php but on each row the number after the names goes up by one. in total there are 5 rows, so for example to field pick is named pick1 on the first row, pick2 on the second... so on to pick5 on the fifth row.
Code: Select all
<?
$hostname ="localhost";
$user = "root";
$pass = "root_pass"; //these are set
$database = "database_name"; //these are set
// Connects to your Database
$connect = mysql_connect($hostname, $user, $pass);
mysql_select_db($database, $connect);
echo ("connected");
if (isset($_POST['submit'])) {
$i=1;
while($i<=5) {
if(isset($_POST['pick$i'])) {
mysql_query("INSERT INTO jobs (ts, pick, addr, dest, tonn, driv, invc ,subc, span, completed) VALUES (ts, '$_POST[pick$i]', '$_POST[addr$i]', '$_POST[dest$i]', '$_POST[tonn$i]', '$_POST[driv$i]', '$_POST[invn$i]', '$_POST[subc$i]', '$_POST[span$i]', no)",$connect);
//echo ("<br>Inserted<br>");
}
$i++;
}
}
?>