Help my data keeps disappearing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bodycount
Forum Newbie
Posts: 3
Joined: Wed Apr 14, 2010 8:52 am

Help my data keeps disappearing

Post by bodycount »

Hi All

I am looking for a bit of help.

What am trying to do is a page where can input 10 pin bowling scores, so what I want to do is to have two drop down menus one to select team 1 and another to select team 2, When you select the first team page refreshes and you have a player list for team 1 , but when I do the same for the second team all the team and players for the first team you have just selected get removed and when I select the first team again the second team and there players disappear.

Any help with my problem would be gratefully appreciated.

Please see code below.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<?php 
    // open connection
include 'connection4.php'; 



//if(isset($_POST['TEAMNAME']) && $_POST['TEAMNAME']) $TEAMNAME = $_POST['TEAMNAME'];
if(isset($_POST['TEAMNAME']) && $_POST['TEAMNAME']) $TEAMNAME1 = $_POST['TEAMNAME'];
if(isset($_POST['TEAM2']) && $_POST['TEAM2']) $TEAMNAME2 = $_POST['TEAM2'];
if(isset($_POST['TEAMNAME2']) && $_POST['TEAMNAME2']) $TEAMNAME3 = $_POST['TEAMNAME2'];
if(isset($_POST['PLAYERNAME']) && $_POST['PLAYERNAME']) $PLAYERNAME = $_POST['PLAYERNAME'];
if(isset($_POST['T2PLAYER']) && $_POST['T2PLAYER']) $PLAYERNAME2 = $_POST['T2PLAYER'];

 ?> 

<html>
<head>
<link rel="stylesheet" type="text/css" href="robtest1.css" />
</head>

<body>
<div id="wrapper">
<fieldset>
<legend>Book RMA</legend>
<?php 

include 'menus.php';

 ?>
<br>
<br>
<br>
<form action="scoresheet_test.php" method="POST">
<div>
<div class="mytext3"><b>Team One</b></div>
<select name="TEAMNAME" onChange="submit();">
<?php
/****************************************************************
*
*     Team One Selection
*
/***************************************************************/
echo"<option>$TEAMNAME</option>";
$query1 = "SELECT DISTINCT TEAMNAME FROM teamlist ORDER BY TEAMNAME ASC";
$result1 = mysql_query($query1);
$num_rows=mysql_num_rows($result1);
while ($row=mysql_fetch_array($result1))
{
$TEAMNAME = $row["TEAMNAME"];
echo "<option value=\"$TEAMNAME\">$TEAMNAME</option>";
}
echo "</select><br></div>";


$query15 = "SELECT * FROM playerlist where TEAMNAME = '$TEAMNAME1'";
    $result15 = mysql_query($query15);
    if($num=mysql_numrows($result15))
    {
      
 while ($record = mysql_fetch_array($result15))
 {


$PLAYERNAME = $record["PLAYERNAME"];

echo "$PLAYERNAME<br>";
}
}
echo "query15 = $query15";
echo "</form>";

/****************************************************************
*
*     Team Two Selection
*
/***************************************************************/

echo "<form action=\"scoresheet_test.php\" method=\"POST\"><div>";
echo "<div class=\"mytext3\"><b>Team Two</b></div>";
echo "<select name=\"TEAMNAME2\" onChange=\"submit();\">";
echo"<option></option>";
$query1 = "SELECT DISTINCT TEAMNAME as TEAM2 FROM teamlist ORDER BY TEAMNAME ASC";
$result1 = mysql_query($query1);
$num_rows=mysql_num_rows($result1);
while ($row=mysql_fetch_array($result1))
{
$TEAMNAME2 = $row["TEAM2"];
echo "<option value=\"$TEAMNAME2\">$TEAMNAME2</option>";
}
echo "</select><br></div>";


$query16 = "SELECT PLAYERNAME as T2PLAYER FROM playerlist where TEAMNAME = '$TEAMNAME3'";
    $result16 = mysql_query($query16);
    if($num=mysql_numrows($result16))
    {
      
 while ($record = mysql_fetch_array($result16))
 {


$PLAYERNAME2 = $record["T2PLAYER"];
echo "$PLAYERNAME2<br>";
}
}
echo "Query16 = $query16";
echo "</form>";

?>
</div>
</div>
</form>
</div>

</body>
</html>
[text][text][text][/text][/text][/text]
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Help my data keeps disappearing

Post by Jade »

You'll need to post more than one team at a time, otherwise you won't be able to figure out which two teams you should be showing.

Code: Select all

<?php
include 'connection4.php'; 

//they selected two players
if ($_POST['playerone'] && $_POST['playertwo'])
{
        //add or update the scores for these players
}

//they haven't selected two teams yet so show them the teams form
if ((!$_POST['teamone'] && !$_POST['teamtwo'])) 
{
?>
<form action=# method=post>
Team One: <select name="teamone">
<?php 
//loop in here to select all teams
</select>
<br/><br/>
Team Two: <select name="teamtwo">
<?php
//loop in here to select all teams
?>
</select>
<center><input type="submit" name="submit" value="Pick Teams" /></center>
</form>
<?php
}
else //they have selected two teams now let them pick players and enter scores
{
?>
<form action=# method=post>
Team One Players:
<select name="playerone">
<?php 
//loop to find all players who belong to $_POST['teamone'];
?>
</select>
<br/><br/>
Enter 10 Scores for Player One:
<?php
//loop to create 10 input boxes for player one scores
?>
<br/><br/>
Team Two Players:
<select name="playertwo">
<?php
//loop to find all players who belong to $_POST['teamtwo'];
?>
</select>
<br/><br/>
Enter 10 Scores for Player Two:
<?php
//loop to create 10 input boxes for player two scores
?>
<center><input type="submit" name="submit" value="Assign Scores" />
</form>
<?php
}
?>
Post Reply