I'm just starting out with PHP/MySQL and have created a database which is fed from an HTML form.
The table concerned (has 4 fields - news_id (primary, auto increment), news_heading, news_article, and news_date (timestamp8).
I have 2 problems:
1) Using phpmyadmin, I can see all 12 rows which have been input, but in trying to display them in a web page, only the first 11 records are shown - the most recent never displays.
2) I don't know how to translate the time from 8 characters (year first) to show as a text type date, eg. 5 January 2003.
My script is:
<?php
$host="blah";
$user="blah";
$password="blah";
$database="apyfc_admin";
$connection = mysql_connect($host, $user, $password)
or die ("couldn't connect to the server - please try again later");
$db = mysql_select_db($database,$connection)
or die ("the database is unavailable - please try again later");
$query = "select * from club_news order by news_id desc";
$result = mysql_query($query)
or die ("Sorry, there are no news items available. Please try later");
$row = mysql_fetch_array($result,mysql_assoc);
/ Display results /
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<h5>$news_heading</h5>\n";
echo nl2br($news_article)."<br><br>\n";
echo "date: ".$news_date;
echo "<br><br>";
echo "<hr>";
}
?>
Any help please? I can't find anything in my books on the first problem and have tried many many ways to solve the second but still haven't managed it.
My brain hurts.