Jump to content


Photo

Results help


  • Please log in to reply
6 replies to this topic

#1 phpbeginner

phpbeginner
  • Members
  • PipPipPip
  • Advanced Member
  • 215 posts

Posted 28 September 2006 - 11:55 AM

I have a somewhat working code that I am trying to fine tune. I'm not too good at the ifs, ands, and buts  ;D .
In the script below you will see I am getting results from a schedules_scores table and I am showing the last game. What I am want to do is to check through schedules_scores table and get the last one which had scores entered into the table and display that. Any help would be greatly appreciated !

<?php
    $result_schedules_scores = mysql_query("SELECT * FROM schedule_scores WHERE season = '000000000001' ORDER BY 'date' DESC LIMIT 1");

$schedules_scores_date = mysql_result($result_schedules_scores,0,"date");
$schedules_scores_location = mysql_result($result_schedules_scores,0,"location");
$schedules_scores_team1 = mysql_result($result_schedules_scores,0,"team1");
$schedules_scores_team2 = mysql_result($result_schedules_scores,0,"team2");
$schedules_scores_team1score = mysql_result($result_schedules_scores,0,"team1_score");
$schedules_scores_team2score = mysql_result($result_schedules_scores,0,"team2_score");
           
echo "
    <tr>
      <td class=\"player_header\" valign=\"top\">
                 <b> $schedules_scores_date <br>
<tr>
      <td class=\"player_header\" valign=\"top\"><img src=\"/games/images/$schedules_scores_team1.jpg\" width=\"50\" border=\"1\" align=\"left\"></td>
  <td class=\"player_header\" valign=\"top\">           <img src=\"/games/images/$schedules_scores_team2.jpg\" width=\"50\" border=\"1\" align=\"left\"></td></b></td></tr>
<tr>
      <td class=\"player_header\" valign=\"top\">
                 <b> $schedules_scores_team1score </td>
<td class=\"player_header\" valign=\"top\">
                 <b> $schedules_scores_team2score </td></tr>
"
?>


#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 28 September 2006 - 12:17 PM

You'd need an additional column, of type timestamp.

This way your date column would hold the date of the match and the timestamp column would hold the time of the last update to the row.  You could 'ORDER BY' either.

An example would be that if a team played one week ago today, my date column would contain 21/09/2006 but your timestamp column would contain 28/09/2006 13:19.
Note: Formats aren't accurate

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 phpbeginner

phpbeginner
  • Members
  • PipPipPip
  • Advanced Member
  • 215 posts

Posted 28 September 2006 - 12:21 PM

Hmmm, the problem is I can do what I can do, which is above, as I am just learning this stuff ( slowly but surely ) and I have no idea on what you are talking about or how to incorporate that into my code.

#4 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 28 September 2006 - 12:25 PM

OK, let me put it another way...

What I am want to do is to check through schedules_scores table and get the last one which had scores entered into the table and display that.


How do you know which the last one to have scores entered was?

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#5 phpbeginner

phpbeginner
  • Members
  • PipPipPip
  • Advanced Member
  • 215 posts

Posted 28 September 2006 - 12:34 PM

I dunno, I guess that's why I asked. Is there someway to check through the table and find out from the schedule_scores table which game was the last to have been played by checking to see if a score was entered or not ?

#6 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 28 September 2006 - 12:39 PM

ok, you could try this:

$result_schedules_scores = mysql_query("SELECT * FROM schedule_scores WHERE season = '000000000001' AND team1_score IS NOT NULL AND team2_score IS NOT NULL ORDER BY 'date' DESC LIMIT 1");

Regards
Huggie
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#7 phpbeginner

phpbeginner
  • Members
  • PipPipPip
  • Advanced Member
  • 215 posts

Posted 28 September 2006 - 12:41 PM

Ahhhh, I think that's exactly what I was looking for. Thanks a bunch !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users