kingsbest Posted August 18, 2011 Share Posted August 18, 2011 Hi All, I'm trying to display the results of fixtures played in the last week and the forthcoming fixtures for the next week, can anyone tell me what's wrong with my code please as im getting an error and im not even sure if this will display what i want? Please keep in mind that im a newbie at PHP thanks. <?php include("includes/db_connect.php"); mysql_select_db($dbname, $con) or die ($dbname); $result = mysql_query("SELECT * FROM scorecards WHERE date <= curdate() AND date >= DATE_SUB(curdate(), INTERVAL 7 day) ORDER BY DESC LIMIT 10"); while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td colspan=\"5\">" . $row['date'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='h5'>" . $row['home_grade_total'] . "</td>"; echo "<td class='h5'><a href='teamhistory.php?name_URL=".$row['home_team']."'>" . $row['home_team'] . "</a></td>"; echo "<td class='h5'>" . $row['result'] . "</td>"; echo "<td class='h5'><a href='teamhistory.php?name_URL=".$row['away_team']."'>" . $row['away_team'] . "</a></td>"; echo "<td class='h5'>" . $row['away_grade_total'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Best wishes, John. Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/ Share on other sites More sharing options...
requinix Posted August 18, 2011 Share Posted August 18, 2011 im getting an error Mind sharing it with us? Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/#findComment-1259167 Share on other sites More sharing options...
kingsbest Posted August 18, 2011 Author Share Posted August 18, 2011 Oops Sorry Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\modsite_fenton\index.php on line 52 line 52-while ($row = mysql_fetch_array($result)) Thanks for looking, John Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/#findComment-1259172 Share on other sites More sharing options...
WebStyles Posted August 18, 2011 Share Posted August 18, 2011 ORDER BY DESC ORDER BY WHAT ? should be ORDER BY FIELDNAME DESC Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/#findComment-1259177 Share on other sites More sharing options...
kingsbest Posted August 18, 2011 Author Share Posted August 18, 2011 lol date, well spotted now i feel a right plonker. Huge thanks. John. Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/#findComment-1259178 Share on other sites More sharing options...
xyph Posted August 18, 2011 Share Posted August 18, 2011 Using mysql_error() when mysql_query() returns FALSE will help you with this. Quote Link to comment https://forums.phpfreaks.com/topic/245147-display-data-from-and-7-days-using-curdate/#findComment-1259190 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.