Good afternoon,

Here is my code:

echo "<table border='1' width='1000'>
<tr>
<th>Date</th>
<th>Name</th>
<th>Book</th>
<th>Subject</th>
<th>Price</th>
<th>Description</th>
<th>Picture</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo '<td><a class="top" href="DetailPage.php?ID=' . $row["ID"];
echo '">' . $row['Date'] . '</a></td>';

echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['book'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['Price'] . "</td>";
echo "<td>" . $row['Description'] . "</td>";
echo "<td>" . "<img src=\"" . $row['picname'] . "\" width=100 height=100 />" . "</td>";
echo "</tr>";
}
echo "</table>";

What I want to do is list the Entries by Date. I want the screen to read Wednesday, Apr 24 and have all the Apr 24 links underneath. Then Tuesday, April 23 and so on and so forth.

My question is how do I list entries by date. The code above work fine, I just need to update it.

Any tips or pointers are appreciated!

    Add an ORDER BY clause to your SELECT query that orders the results by date, then store the date of the current row into a temporary variable inside the while() loop. On each iteration of the loop, you'd then check to see if that date has changed - if so, output a new header row/column/whatever.

      So ... something like:

      $date = $row['date']
      if(!$row['date']=Wednesday)
      {
      echo ...
      }

      I have no idea how to do that.

        if($row['date'] != $date) // You might want to check the manual for the basics of how to compare values
        {
            // The date has changed. Print a header
        }
        $date = $row['date']; // Now printing rows for this date.
        
          Write a Reply...