phpbeginner Posted September 28, 2006 Share Posted September 28, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/ Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100185 Share on other sites More sharing options...
phpbeginner Posted September 28, 2006 Author Share Posted September 28, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100187 Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 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?RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100190 Share on other sites More sharing options...
phpbeginner Posted September 28, 2006 Author Share Posted September 28, 2006 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100196 Share on other sites More sharing options...
HuggieBear Posted September 28, 2006 Share Posted September 28, 2006 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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100199 Share on other sites More sharing options...
phpbeginner Posted September 28, 2006 Author Share Posted September 28, 2006 Ahhhh, I think that's exactly what I was looking for. Thanks a bunch ! Quote Link to comment https://forums.phpfreaks.com/topic/22365-results-help/#findComment-100201 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.