Jump to content

[SOLVED] query is only displaying one field, and not the rest ?


egiblock

Recommended Posts

$query_PlayerListName = "SELECT * FROM tbl_players WHERE tbl_players.playerID = $id";
$PlayerListName = mysql_query($query_PlayerListName, $golfscoring) or die(mysql_error());
$row_PlayerListName = mysql_fetch_assoc($PlayerListName);
$totalRows_PlayerListName = mysql_num_rows($PlayerListName);

$query_PlayerDetail = "SELECT tbl_players.playerID, tbl_courses.CourseName, tbl_events.eventName, (tbl_scores.s1 + tbl_scores.s2 + tbl_scores.s3 + tbl_scores.s4 + tbl_scores.s5 + tbl_scores.s6 + tbl_scores.s7 +tbl_scores.s9 + tbl_scores.s8 + tbl_scores.s12 + tbl_scores.s11 + tbl_scores.s10 + tbl_scores.s18 + tbl_scores.s17 +tbl_scores.s16 + tbl_scores.s15 + tbl_scores.s14 + tbl_scores.s13) AS totalScore, tbl_events.eventDateTime, tbl_players.PlayerName FROM tbl_scores Inner Join tbl_courses ON tbl_scores.courseID = tbl_courses.courseID Inner Join tbl_players ON tbl_players.playerID = tbl_scores.playerID Inner Join tbl_events ON tbl_scores.eventID = tbl_events.eventID WHERE tbl_scores.playerID = $id";
$PlayerDetail = mysql_query($query_PlayerDetail, $golfscoring) or die(mysql_error());
$row_PlayerDetail = mysql_fetch_assoc($PlayerDetail);
$totalRows_PlayerDetail = mysql_num_rows($PlayerDetail);

 

in my html document i have:

 

<b> <?php echo $row_PlayerListName['PlayerName']; ?> </b>

<br><br>

 

 

then for the results i have the following table:

 

<table width="100%" border="0" cellspacing="2" cellpadding="0">
      <tr>
        <td align="center"><strong>Date of Event</strong></td>
        <td align="center"><strong>Course Name</strong></td>
        <td align="center"><strong>Event Name</strong></td>
        <td align="center"><strong>Total Score</strong></td>
      </tr>
      
<?php
if($PlayerDetail) 
{
while($row = mysql_fetch_row($PlayerDetail)) 
{
echo "<tr><td>";
echo date('M j, Y g:i a', strtotime($row['eventDateTime'])); 
echo "</td><td>";
echo $row['CourseName']; 
echo "</td><td>";
echo $row['eventName']; 
echo "</td><td>";
echo $row['totalScore']; 
echo "</td></tr>";
}

while($row2 = mysql_fetch_array($PlayerDetail))
{
echo "<tr><td>";
echo date('M j, Y g:i a', strtotime($row2['eventDateTime'])); 
echo "</td><td>";
echo $row2['CourseName']; 
echo "</td><td>";
echo $row2['eventName']; 
echo "</td><td>";
echo $row2['totalScore']; 
echo "</td></tr>";
}
} 

?>
    </table>

 

 

all that is displaying on the page is the date "eventDateTime" in the table, and the echo'd player name at the top of the page, but nothing else.

 

any ideas ?

 

 

Link to comment
Share on other sites

Hi

 

Nothing I can see directly, but you grab the first row only for $row_PlayerDetail, the loop round after that will be the 2nd row onwards and your last loop won't bring anything back

 

All the best

 

Keith

 

thanks..

 

i'll have to look at it some more again tomorrow...  i can get it sometimes to display the 1st record, and nothing else, and then the 2-whatever records another time, but not the first...  so i'll have to check it out when i have a clear head.

 

 

Link to comment
Share on other sites

Hi

 

Nothing I can see directly, but you grab the first row only for $row_PlayerDetail, the loop round after that will be the 2nd row onwards and your last loop won't bring anything back

 

All the best

 

Keith

 

 

it was the $row compared to $row_playerdetail that threw me off.

 

this code works..

 

<?php

if($PlayerDetail) 
{
   echo "<tr><td>";
   echo date('M j, Y g:i a', strtotime($row_PlayerDetail['eventDateTime'])); 
   echo "</td><td>";
   echo $row_PlayerDetail['CourseName']; 
   echo "</td><td>";
   echo $row_PlayerDetail['eventName']; 
   echo "</td><td>";
   echo $row_PlayerDetail['totalScore']; 
   echo "</td></tr>";
}

while($row = mysql_fetch_array($PlayerDetail))
{
echo "<tr><td>";
echo date('M j, Y g:i a', strtotime($row['eventDateTime'])); 
echo "</td><td>";
echo $row['CourseName']; 
echo "</td><td>";
echo $row['eventName']; 
echo "</td><td>";
echo $row['totalScore']; 
echo "</td></tr>";
}
?>

 

 

i also took out the first "where" statement, and i finally got it !!!

 

thanks !!!!!  8) 8)

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.