easy question about displaying mysql records
Posted: Wed Apr 18, 2007 3:58 pm
feyd | Please use
how can I modify this code to display the next 7 days and the next 30 days?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have recently found out how to display today's records from mysql, but now I want to display the records for the next 7 days as well as records from the next 30 days.
Here is my current code:Code: Select all
<?php
$today = date("Y-m-d");
echo "Event Listing for " . $today
?>
<?php
$con = mysql_connect("localhost","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("jcsickz_mc", $con);
$result = mysql_query("SELECT * FROM events WHERE date = '" . $today ."' ORDER BY date DESC");
echo "<table border='1'>
<tr>
<th>Date</th>
<th>Time</th>
<th>Venue</th>
<th>Description</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['time'] . "</td>";
echo "<td>" . $row['venue'] . "</td>";
echo "<td>" . $row['description'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]