php - How do i submit mulitple forms, using the same action, using a single button -


so, have looked through forum, , not found case similar mine on topic.

i trying create form gives 9 options, each option 2 choices, give total of 18 possibilities. final 9 options, submit, via post method, php file, use information update sql database.

i have got point in code, , have not been able find, or bring elements need make work.

    <table border="2">   <tr> <td colspan="2" align="center">game 1</td></tr>   <form>  <tr height="40px"><td><input type="radio" name="game1" value="home"/> home </td><td><input type="radio" name="game1" value="away" /> away</td></tr></form>  <tr> <td colspan="2" align="center">game 2</td></tr> <form><tr height="40px"><td><input type="radio" name="game2" value="home" /> home</td><td><input type="radio" name="game2" value="away" /> away </td></tr></form> 

game 3 home away game 4 home away game 5 home away game 6 home away game 7 on under game 8 on under game 9 on under

</table> <input type="button" value="muli-submit" onclick="$('.form').submit()" /> 

now not sure, correct functionality, idea 1 button submits each of 9 forms, values each of games this:

<form action="update9.php" method="post"> 

thus creating list of values used in php such:

  <?php  $member=$_post["member"]; $game1=$_post["game1"]; $game2=$_post["game2"]; $game3=$_post["game3"]; $game4=$_post["game4"]; $game5=$_post["game5"]; $game6=$_post["game6"]; $game7=$_post["game7"]; $game8=$_post["game8"]; $game9=$_post["game9"];      // connect database server mysql_connect("efootyonline.ipagemysql.com", "user", password") or die (mysql_error ());  // select database mysql_select_db("web_footy1") or die(mysql_error());   // sql statement built  $strsql = "update round_9 set ";  $strsql = $strsql . "game1= '$game1', "; $strsql = $strsql . "game2= '$game2', ";  $strsql = $strsql . "game3= '$game3', ";  $strsql = $strsql . "game4= '$game4', ";  $strsql = $strsql . "game5= '$game5', ";  $strsql = $strsql . "game6= '$game6', ";  $strsql = $strsql . "game7= '$game7', ";  $strsql = $strsql . "game8= '$game8', ";  $strsql = $strsql . "game9= '$game9' ";  $strsql = $strsql . "where  member = '$member' ";   // sql statement executed  mysql_query($strsql) or die(mysql_error()) ;  // close database connection mysql_close();  ?> 

the database updated!

thanks in advance. self taught, 2 months developing , refine site work in progress.

you don't need have separate forms. use 1 form..!

<table border="2">     <form>         <tr>             <td colspan="2" align="center">game 1</td>         </tr>          <tr height="40px">             <td><input type="radio" name="game1" value="home"/> home</td>             <td><input type="radio" name="game1" value="away"/> away</td>         </tr>         <tr>             <td colspan="2" align="center">game 2</td>         </tr>         <tr height="40px">             <td><input type="radio" name="game2" value="home"/> home</td>             <td><input type="radio" name="game2" value="away"/> away</td>         </tr>     </form> </table> 

also, easier work info if load values each game array rather having separate variables.

you can naming elements , specifying index in brackets game[1].

so using:

<table border="2">     <form method="post" action="http://eqtracker.com/testing.php">         <tr>             <td colspan="2" align="center">game 1</td>         </tr>          <tr height="40px">             <td><input type="radio" name="game[1]" value="home"/> home</td>             <td><input type="radio" name="game[1]" value="away"/> away</td>         </tr>         <tr>             <td colspan="2" align="center">game 2</td>         </tr>         <tr height="40px">             <td><input type="radio" name="game[2]" value="home"/> home</td>             <td><input type="radio" name="game[2]" value="away"/> away</td>         </tr>         <tr>             <td colspan="2" align="center">game 3</td>         </tr>         <tr height="40px">             <td><input type="radio" name="game[3]" value="home"/> home</td>             <td><input type="radio" name="game[3]" value="away"/> away</td>         </tr>         <button type="submit">submit info</button>     </form> </table> 

would single array called game loaded values.

array(1) {   ["game"]=>   array(3) {     [1]=>     string(4) "home"     [2]=>     string(4) "away"     [3]=>     string(4) "home"   } } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -