Jump to content

Posting to Database


BelowZero

Recommended Posts

You guys helped me create a function to gather information for my database. Now I need some help with posting that information.

 

Function code and Form:

<?php include("opendatabase.php"); ?>	

<?php
function createMatchup($week, $game)
{
$query1 = "SELECT team_name 
FROM schedule, teams 
WHERE schedule.week_id = $week 
AND schedule.game_id = $game 
AND schedule.A_team = teams.team_id";

$query2 = "SELECT team_name 
FROM schedule, teams 
WHERE schedule.week_id = $week 
AND schedule.game_id = $game 
AND schedule.H_team = teams.team_id";

$result1 = mysql_fetch_assoc(mysql_query($query1));
$result2 = mysql_fetch_assoc(mysql_query($query2));

$output = "
<input type=\"text\" size = \"3\" name=\"w$weekg$gameA\"> {$result1['team_name']} vs. {$result2['team_name']} 
<input type=\"text\" size = \"3\" name=\"w$weekg$gameH\">";

return $output;

}

$game1 = createMatchup(1, 1);
$game2 = createMatchup(1, 2);
$game3 = createMatchup(1, 3);
$game4 = createMatchup(1, 4);
$game5 = createMatchup(1, 5);
$game6 = createMatchup(1, 6);
$game7 = createMatchup(1, 7);
$game8 = createMatchup(1, ;
$game9 = createMatchup(1, 9);
$game10 = createMatchup(1, 10);
$game11 = createMatchup(1, 11);
$game12 = createMatchup(1, 12);
$game13 = createMatchup(1, 13);
$game14 = createMatchup(1, 14);
$game15 = createMatchup(1, 15);
$game16 = createMatchup(1, 16);

mysql_close($con);

?>

<form action="insert_spreads.php" method="post">
<?php echo $game1; ?>
<br>
<?php echo $game2; ?>
<br>
<?php echo $game3; ?>
<br>
<?php echo $game4; ?>
<br>
<?php echo $game5; ?>
<br>
<?php echo $game6; ?>
<br>
<?php echo $game7; ?>
<br>
<?php echo $game8; ?>
<br>
<?php echo $game9; ?>
<br>
<?php echo $game10; ?>
<br>
<?php echo $game11; ?>
<br>
<?php echo $game12; ?>
<br>
<?php echo $game13; ?>
<br>
<?php echo $game14; ?>
<br>
<?php echo $game15; ?>
<br>
<?php echo $game16; ?>
<br /><br />
<input type="Submit" value="Submit Spreads">
</form>

I'm wondering if I can use this code for posting to the database (insert_spreads.php):

<?php	

header("Location: admin_schedule.php");

include("opendatabase.php");

$w$weekg$gameA=("$_POST['w$weekg$gameA']");
$w$weekg$gameH=("$_POST['w$weekg$gameH']");

$sql="
UPDATE schedule 
SET A_pt_spread= '$w$weekg$gameA',H_pt_spread= '$w$weekg$gameH'
WHERE week_id = '$week'
AND game_id = '$game';

$result = mysql_query($sql) or die(mysql_error().$sql);

mysql_close($con)

?>

 

Thanks for helping.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.