Please could someone kindly help me out with the below? Basically I'm pulling information back from mysql database in the form of football teams and then I've managed to put a drop down next to each of them in order for the user to choose the score. I then can't insert that value into my predictions table:
Code: Select all
<?php
$goals = array ("0", "1", "2","3", "4", "5","6", "7", "8","9", "10");
$conn = mysql_connect("localhost","root","swarve") or die(mysql_error());
mysql_select_db("predictions");
$sql = processInput();
function processInput(){
//extract information from above
$WeekNo = $_POST["WeekNo"];
$sql = "SELECT name
FROM `fixtures_table`
INNER JOIN teams_table ON Home_Team_ID = Team_ID
WHERE WeekNo = '$WeekNo'
ORDER BY ID";
return $sql;
} // end processInput
$result = mysql_query($sql, $conn) or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
foreach ($row as $name => $value){
print "$value";
echo "<select>";
foreach($goals as $goal)
{
echo "<option name='$goal'>$goal</option> <br />\n";
}
echo "</select>";
} // end foreach
print "<br> <br />\n";
} //end while
?>
I'm then trying to insert this into my predictions_table:
<?php
$conn = mysql_connect("localhost","root","swarve") or die(mysql_error());
mysql_select_db("predictions");
$GoalInsert = $_POST['$goal'];
$sql = "INSERT INTO predictions_table (,Home_Prediction,Away_Prediction)VALUES ('$GoalInsert','$GoalInsert')";
$result = mysql_query($sql, $conn) or die(mysql_error());
?>Thanking you in advance for any help you could give me.
Thanks,
Dave