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. 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? 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 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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.