Jump to content

radio buttons


jawood

Recommended Posts

Hi, hopping someone can help with a problem im having getting a vaiable assigned to a radio button name.

 

the code is as follows..  The bits in bold are where my problem lies...

 

Any assistance would be great, thanks

 

<?php # add_winning_teams.php

 

session_name ('YourVisitID');

session_start();

 

$page_title = 'Add Winning Teams!';

include ('./includes/header.html');

include_once ('./includes/databaseconnect.php');

echo "<h1>Select Winners</h1>";

$dayname = date("l");

$daydate = date("d");

$month = date("F");

$year = date("o");

//$match = array();

if (isset($_POST['submitted'])) {

 

$gw = escape_data($_POST['game_week']);

 

$query = "SELECT match_id, home_team, away_team, game_day_name, game_day, game_month, game_year, game_week FROM matches WHERE (game_week='$gw')";

$result = mysql_query ($query);

echo "<h2>Check the winners</h2>";

$i = 1;

while($row = mysql_fetch_array($result)) {

 

echo $row[1] . '<input type="radio" name="match' . $row[0] . '" value="' . $row[1] . '" /> Vs ' . $row[2];

 

$i++;

echo "<input type='radio' name='$row[0]' value='$row[2]' />";

echo " on $row[3] the $row[4]th of $row[5] $row[6]<br />";

 

$i++;

}

 

?>

<form action="add_winning_teams.php" method="post"/>

<br /><input type='submit' name='submit1' value='Submit Winners'/>

<?php

 

}

if (isset($_POST['submit1'])) {

echo "<br /><br />Submitted";

$query = "SELECT match_id, home_team, away_team, game_day_name, game_day, game_month, game_year, game_week FROM matches WHERE (game_week='$gw')";

$result = mysql_query ($query);

while ($row = mysql_fetch_array($result)) {

echo "<br />Winner of match $row[1] Vs $row[2] is " . $_POST['match'] . " ";

}

//foreach ($_POST['match{$row[0]}'] as $msg) { // Print each error.

// echo "  $msg<br />\n";

// }

}

 

 

?>

<h3>Select Round to View.</h3>

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

 

<p><label><select name="game_week" id="game_week">

<option selected="selected"><?php if (isset($_POST['game_week'])) { echo $_POST['game_week']; } else { echo "1"; } ?></option>

    <option>1</option>

    <option>2</option>

    <option>3</option>

    <option>4</option>

    <option>5</option>

    <option>6</option>

    <option>7</option>

    <option>8</option>

    <option>9</option>

    <option>10</option>

    <option>11</option>

    <option>12</option>

    <option>13</option>

    <option>14</option>

    <option>15</option>

    <option>16</option>

    <option>17</option>

    <option>18</option>

    <option>19</option>

    <option>20</option>

    <option>21</option>

    <option>22</option>

    <option>23</option>

    <option>24</option>

    <option>25</option>

  </select>

</label></p>

<p><input type="submit" name="submit" value="View" /></p>

 

<input type="hidden" name="submitted" value="TRUE" />

 

</form>

 

<?php

include ('./includes/footer.html');

?>

Link to comment
https://forums.phpfreaks.com/topic/69415-radio-buttons/
Share on other sites

Well the code prints out the home and away teams of a footy match with radio buttons to select the winning teams and a submit button. When you select the winning teams and hit the sun\bmit button it should print out the teams and the winner of the match but all i get is the teams with a blank where the winner should be....

Link to comment
https://forums.phpfreaks.com/topic/69415-radio-buttons/#findComment-348768
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.