Hello.
I have this code:
[php]
<?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"); // Get date from _GET param or current date if not available $_GET['date'] = @trim(stripslashes($_GET['date'])); $date = ($_GET['date'] && !empty($_GET['date'])) ? date('Y-m-d', strtotime(trim($_GET['date']))) : date('Y-m-d'); $result = mysql_query('SELECT * FROM news WHERE Date = "' . $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)) { extract ($row); print "$Title$News
$Date $Time
"; } print "
"; ++$rowcount; } } ?>
[/php]
I have a table (called news) in a MySQL database with 5 fields: (News, Title, Date, Time). The code works. However, when I display the results, it shows the same thing 5 times.
This is what shows:
[b]News system up and running![/b] We finally have this news system working. If you want to see older news (by date), just click the arrow on top. 2007-01-12 13:12:42News system up and running!
We finally have this news system working. If you want to see older news (by date), just click the arrow on top.
2007-01-12 13:12:42News system up and running!
We finally have this news system working. If you want to see older news (by date), just click the arrow on top.
2007-01-12 13:12:42News system up and running!
We finally have this news system working. If you want to see older news (by date), just click the arrow on top.
2007-01-12 13:12:42News system up and running!
We finally have this news system working. If you want to see older news (by date), just click the arrow on top.
2007-01-12 13:12:42
How can I make it so that it only shows a news post ONCE?
PS: I think it’s because of the extract($row) thing.