Hello, I am using the code below to enter information in my table. What I would like is the ability to enter multiple rows into the db with only one query. Right now I have one <option> field with the value getting inserted into the table.
<select name="gk">
<option value="1" selected="selected">Jens Lehman</option>
<option value="13">Stuart Taylor</option>
<option value="33">Graham Stack</option>
</select>
<br>
<input type="Submit" name="submit" value="Add">
Then this PHP to enter that into the table.
<?
}
else
{
// includes
include("testjaslkjtphp");
// set up error list array
$errorList = array();
$count = 0;
// validate text input fields
if (!$gk) { $errorList[$count] = "Invalid entry: Goalkeeper"; $count++; }
// check for errors
// if none found...
if (sizeof($errorList) == 0)
{
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// generate and execute query
$query = "INSERT INTO match_squad(match_id, player_id, team_id) VALUES(6, $gk, 1)";
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
// print result
echo "Update successful. <a href='hme.php;>Go back to the main menu</a>.</font>";
// close database connection
mysql_close($connection);
}
else
{
// errors found
// print as list
echo "<font size=-1>The following errors were encountered: <br>";
echo "<ul>";
for ($x=0; $x<sizeof($errorList); $x++)
{
echo "<li>$errorList[$x]";
}
echo "</ul></font>";
}
}
?>
What I would like is to do this:
<select name="gk">
<option value="1" selected="selected">Jens Lehman</option>
<option value="13">Stuart Taylor</option>
<option value="33">Graham Stack</option>
</select>
<br>
<select name="outf1">
<option value="3" selected="selected">Ashley Cole</option>
<option value="4">Patrick Vieira</option>
<option value="5">Martin Keown</option>
<option value="7">Robert Pires</option>
<option value="8">Freddie Ljungberg</option>
</select>
<br>
<input type="Submit" name="submit" value="Add">
Then insert into match_squad gk and outf1 both.