Hi,
I'm a PHP newbie, and trying to make linkable lists of the most recent articles in the database for my web pages.
I know I need to use an if loop, but just am not getting it right ...
Here's the code, without the if loop added ...
//connect
webcontent_connect()
or exit ();
//build SQL query
$sql = "select title, article_id
from articles
order by date desc limit 3";
//actually issue it
$result = mysql_query ($sql) or die("Couldn't issue query!");
while ($row = mysql_fetch_array ($result))
{
$title = $row["title"];
$article_id = $row["article_id"];
}
echo "<a href=\"/articles/$article_id.php\">$title</a><br>";
This code is just, as you'll see, linked the last retrieved row, not all three.
How can I build something that will list all three titles, and link the titles to their articles (links based on article_id number, as you can see, and go to the /articles directory).
Would appreciate any help you can give me!
Thanks.