Jump to content

Archived

This topic is now archived and is closed to further replies.

phpbeginner

Results help

Recommended Posts

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 !

[sup]<?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>
"
?>[/sup]

Share this post


Link to post
Share on other sites
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.
[color=red][size=8pt]Note: Formats aren't accurate[/size][/color]

Regards
Huggie

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
OK, let me put it another way...

[quote]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.[/quote]

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

Regards
Huggie

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
ok, you could try this:

[code]
$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");
[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites

×

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.