Jump to content

select where date column - today?


flemingmike

Recommended Posts

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.

Link to comment
Share on other sites

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>";




  }

Link to comment
Share on other sites

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>";
  }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.