the team data for each player is in recordset1, but the players names are in recordset2, both tables have the players id#, so after calling only the players form the selected team name from recordset1, but I want the players names to show in the dropdown menu, so I told it to match-up the id#s from the 2 tables and display the names. But it seems it is not recalculating the value of $recordset2 becuase it is displaying the same name over and over in the drop down list. Thank you for your help.
PHP Code:
<?php virtual('/Connections/localhost.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_Recordset1 = "-1"; if (isset($_GET['MyTeam'])) { $colname_Recordset1 = $_GET['MyTeam']; } mysql_select_db($database_localhost, $localhost); $query_Recordset1 = sprintf("SELECT id FROM yearly_player_info WHERE team = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); $colname_Recordset2 = "-1"; if (isset($row_Recordset1['id'])) { $colname_Recordset2 = $row_Recordset1['id']; } mysql_select_db($database_localhost, $localhost); $query_Recordset2 = sprintf("SELECT name FROM players WHERE id = %s", GetSQLValueString($colname_Recordset2, "int")); $Recordset2 = mysql_query($query_Recordset2, $localhost) or die(mysql_error()); $row_Recordset2 = mysql_fetch_assoc($Recordset2); $totalRows_Recordset2 = mysql_num_rows($Recordset2); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Confirm</title> <style type="text/css"> <!-- .abcd { font-family: Georgia, "Times New Roman", Times, serif; font-size: small; } .style2 { font-weight: bold; color: #666666; font-family: "Times New Roman", Times, serif; font-style: italic; } --> </style> </head> <body> <div align="left"> <p> <?php $Myteam = $_GET['MyTeam'];?> <span class="style2"><sup>My Team: </sup></span><img src="tico/<?php echo $_GET['MyTeam'];?>.gif" /><span class="abcd"><?php echo $Myteam;?></span></p> </div> <form id="form1" name="form1" method="post" action=""> <label> <select name="select" id="select"> <option value="pk1">Draft Pick 1</option> <option value="pk2">Draft Pick 2</option> <option value="pk3">Draft Pick 3</option> <option value="pk4">Draft Pick4</option> <?php do { ?> <option value="<?php echo $row_Recordset1['id']?>"><?php echo $row_Recordset2['name']?></option> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); $rows = mysql_num_rows($Recordset1); if($rows > 0) { mysql_data_seek($Recordset1, 0); $row_Recordset1 = mysql_fetch_assoc($Recordset1); } ?> </select> </label> </form> <p> </p> </body> </html> <?php mysql_free_result($Recordset1); mysql_free_result($Recordset2); ?>
|