Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Menu Displaying Wrong Label
Old 02-09-2009, 08:06 PM Menu Displaying Wrong Label
Junior Talker

Posts: 4
Trades: 0
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($Recordset10);
   
$row_Recordset1 mysql_fetch_assoc($Recordset1);
  }
?>
  </select>
  </label>
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result
($Recordset1);
mysql_free_result($Recordset2);
?>
cjvolcom is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-10-2009, 04:39 PM Re: Menu Displaying Wrong Label
Junior Talker

Posts: 4
Trades: 0
bump?
cjvolcom is offline
Reply With Quote
View Public Profile
 
Old 02-11-2009, 12:18 PM Re: Menu Displaying Wrong Label
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Use a JOIN query instead of trying to synchronise two disconnected recordsets
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Menu Displaying Wrong Label
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.42073 seconds with 12 queries