Ok, I mentioned that my seed column is fixed so it is like this:
teamid | seed | id
Team C | r1 | 1
Team Z | r2 | 2
Team P | r3 | 3
Team K | r4 | 4
Team J | r5 | 5
Well, you get the picture now. The goal is to update teamid at anytime while seed field will always remain fixed. And it will allow me to SELECT teamid where ranking is.
So with table above, I developed a page and let's name it includeselect.php for now. The purpose of includeselect.php is to put it on top of all pages so when I use <? php echo $ncaa5; ?> in HTML, then it will display team in the database. It reads like this:
<?php
*connect to mysql & select database code here*
$iLoop = 0;
$query ="SELECT teamid FROM gameresults";
$result =mysql_query($query) or die(mysql_error());
while($res = mysql_fetch_array($result))
{
if($iLoop == 0)
{
$ncaa1 = $res[0];
}elseif($iLoop == 1) {
$ncaa2 = $res[0];
}elseif($iLoop == 2) {
$ncaa3 = $res[0];
}elseif($iLoop == 3) {
$ncaa4 = $res[0];
}elseif($iLoop == 4) {
$afc5 = $res[0];
}elseif($iLoop == 5) {
$ncaa6 = $res[0];
}elseif($iLoop == 6) {
$ncaa7 = $res[0];
}elseif($iLoop == 7) {
$ncaa8 = $res[0];
}elseif($iLoop == 8) {
$ncaa9 = $res[0];
}elseif($iLoop == 9) {
$ncaa10 = $res[0];
}elseif($iLoop == 10) {
$ncaa11 = $res[0];
}elseif($iLoop == 11) {
$ncaa12 = $res[0];
}
$iLoop = $iLoop + 1;
}
include ('endb.php');
?>
For form page: (We will use 2 input value for this instead of 12 for easy finding)
<? php
include ('includeselect.php');
?>
<form action="add_teams.php" method="POST">
<table width="300" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="text">NCAA #1:</td>
<td><INPUT TYPE="text" NAME="TeamOne" SIZE="25" MAXLENGTH="25" VALUE="<?php echo $ncaa1; ?>"></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td class="text">NCAA #2:</td>
<td><INPUT TYPE="text" NAME="TeamTwo" SIZE="25" MAXLENGTH="25" VALUE="<?php echo $ncaa2; ?>"></td>
</tr>
</table>
<br>
<input type="submit" name="Submit" value="SUBMIT"></form>
And now for the update page to UPDATE team info into teamid fields:
<?php
include ('includeselect.php');
$sql = "UPDATE tablename SET teamid='$teamOne', teamid='$teamTwo' WHERE seed='r1', seed='r2'";
$result = mysql_query($sql);
if(!$result){
echo "Error inserting your information into MySQL' mysql_error()";
}
echo '<center><br><span class="text">Success! NCAA Teams has been updated!</span></br></center>';
include ('endb.php');
?>