john010117
January 12th, 2007, 01:03 AM
Hello. I have the following code so far.
<?php
// Connection information
$db_host = "localhost";
$db_user = "***";
$db_pass = "***";
$db_name = "***";
// Connect to server
$dbac = mysql_connect($db_host,$db_user,$db_pass);
$today = getdate();
// Select database
mysql_select_db ($db_name) or die ("Cannot connect to database");
// Change is here added [ = '{$_GET['date']}' ] to end. Which get ?date=____ from url.
$result = mysql_query("SELECT * FROM news WHERE Date = '{$_GET['date']}' ORDER BY Time");
$curtime = time();
if ($result && mysql_num_rows($result)) {
$numrows = mysql_num_rows($result);
$rowcount = 1;
while ($row = mysql_fetch_assoc($result)) {
while(list($var, $val) = each($row)) {
print "<B>$var</B>: $val<br />";
}
print "<br />";
++$rowcount;
}
}
?>
As you can see, it stores information in a table called "news". If I type in index.php?date=2007-01-06, it gets the news only for that day.
I was wondering. How can I make it so that when I type in index.php, it automatically gets the news for today (but I'm typing up the news). Anybody know how to?
<?php
// Connection information
$db_host = "localhost";
$db_user = "***";
$db_pass = "***";
$db_name = "***";
// Connect to server
$dbac = mysql_connect($db_host,$db_user,$db_pass);
$today = getdate();
// Select database
mysql_select_db ($db_name) or die ("Cannot connect to database");
// Change is here added [ = '{$_GET['date']}' ] to end. Which get ?date=____ from url.
$result = mysql_query("SELECT * FROM news WHERE Date = '{$_GET['date']}' ORDER BY Time");
$curtime = time();
if ($result && mysql_num_rows($result)) {
$numrows = mysql_num_rows($result);
$rowcount = 1;
while ($row = mysql_fetch_assoc($result)) {
while(list($var, $val) = each($row)) {
print "<B>$var</B>: $val<br />";
}
print "<br />";
++$rowcount;
}
}
?>
As you can see, it stores information in a table called "news". If I type in index.php?date=2007-01-06, it gets the news only for that day.
I was wondering. How can I make it so that when I type in index.php, it automatically gets the news for today (but I'm typing up the news). Anybody know how to?