HELP!
I've looked through many posts asking this same question and followed several tutorials for inputting multiple records using one INSERT, but can't seem to get this to work.
The result is the only the second record being entered into the database, twice, being signed consecutive auto increment bowling_id numbers.
The form:
The processing:
Thanks for any answers you can provide!
I've looked through many posts asking this same question and followed several tutorials for inputting multiple records using one INSERT, but can't seem to get this to work.
The result is the only the second record being entered into the database, twice, being signed consecutive auto increment bowling_id numbers.
The form:
Code:
<form action="bowlingscoresprocess.php" method="post"> <table width="600" border="2" cellspacing="2" cellpadding="2"> <tr> <th scope="col">ID</th> <th scope="col">Date</th> <th scope="col">Name</th> <th scope="col">Game 1</th> <th scope="col">Game 2</th> </tr> <tr> <td><input type="text" name="bowlscores_id" value=""></td> <td><input type="text" name="bowldate" value="Thursday, Mar 1, 2013"></td> <td><input type="text" name="bowllastfirst" value="Smith, Joe"></td> <input type="hidden" name="bowlfirstlast" value="Joe Smith"> <td><input type"text" name="bowlgamea"></td> <td><input type="text" name="bowlgameb"></td> </tr> <tr> <td><input type="text" name="bowlscores_id" value=""></td> <td><input type="text" name="bowldate" value="Thursday, Mar 1, 2013"></td> <td><input type="text" name="bowllastfirst" value="Johnson, Sam"></td> <input type="hidden" name="bowlfirstlast" value="Sam Johnson"> <td><input type"text" name="bowlgamea"></td> <td><input type="text" name="bowlgameb"></td> </tr> </table> <center> <table border="0" cellspacing="1" cellpadding="3" align="center"> <tr> <td colspan=2 align="center"> <input type="submit" name="Submit" value="Submit"> </td> <td width="5"> </td> <td colspan=2 align="center"> <input type="reset" name="reset" value="Reset "/> </td> </tr> </table>
The processing:
Code:
<?php $con = mysql_connect("localhost", "mydatabase", "password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("mydatabase", $con); $sql="INSERT INTO bowlingscores (bowlscores_id, bowldate, bowllastfirst, bowlfirstlast, bowlgamea, bowlgameb) VALUES ('$_POST[bowlscores_id]','$_POST[bowldate]','$_POST[bowllastfirst]','$_POST[bowlfirstlast]','$_POST[bowlgamea]','$_POST[bowlgameb]'), ('$_POST[bowlscores_id]','$_POST[bowldate]','$_POST[bowllastfirst]','$_POST[bowlfirstlast]','$_POST[bowlgamea]','$_POST[bowlgameb]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Records added"; mysql_close($con); ?>
Comment