flemingmike Posted September 19, 2010 Share Posted September 19, 2010 is it possible to do something like $today = date("Y-m-d"); $result = mysql_query("SELECT * FROM staff where date = '.$today.' "); also, is it normal for the first entry in the database not to be displayed? i have 6 entries in a table and only 2-6 are shown. when i changed the id for 1 to 7, it only displayed 3-7. Quote Link to comment https://forums.phpfreaks.com/topic/213791-select-where-date-column-today/ Share on other sites More sharing options...
flemingmike Posted September 19, 2010 Author Share Posted September 19, 2010 ok, so i got it to display just records with todays date. it still isnt displaying the first record though. $result = mysql_query("SELECT * FROM staff WHERE date >= '".date('Y-m-d').' 00:00:00'."' AND date < '".date('Y-m-d').' 23:59:59'."' "); while($row = mysql_fetch_array($result)) { echo "<table border='1'> <tr> <th>ID</th> <th>Name</th> <th>Job Number</th> <th>Date</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row["ID"] . "</td>"; echo "<td>" . $row["Name"] . "</td>"; echo "<td>" . $row["jobNO"] . "</td>"; echo "<td>" . $row["Date"] . "</td>"; echo "</tr>"; } echo "</table>"; } Quote Link to comment https://forums.phpfreaks.com/topic/213791-select-where-date-column-today/#findComment-1112711 Share on other sites More sharing options...
trq Posted September 19, 2010 Share Posted September 19, 2010 Why do you have two while() statements? The first time you call mysql_fetch_array() (in your first while()) you never use the data it returns (this holds your first record). Quote Link to comment https://forums.phpfreaks.com/topic/213791-select-where-date-column-today/#findComment-1112727 Share on other sites More sharing options...
flemingmike Posted September 19, 2010 Author Share Posted September 19, 2010 so what would i change the first while to? Quote Link to comment https://forums.phpfreaks.com/topic/213791-select-where-date-column-today/#findComment-1112789 Share on other sites More sharing options...
trq Posted September 20, 2010 Share Posted September 20, 2010 You should remove it altogether. if ($result = mysql_query("SELECT * FROM staff WHERE date >= '".date('Y-m-d').' 00:00:00'."' AND date < '".date('Y-m-d').' 23:59:59'."' ") { if (mysql_num_rows($result)) { echo "<table border='1'> <tr> <th>ID</th> <th>Name</th> <th>Job Number</th> <th>Date</th> </tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row["ID"] . "</td>"; echo "<td>" . $row["Name"] . "</td>"; echo "<td>" . $row["jobNO"] . "</td>"; echo "<td>" . $row["Date"] . "</td>"; echo "</tr>"; } echo "</table>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/213791-select-where-date-column-today/#findComment-1113130 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.