Hello...Not a PHP coder in the least bit. I have designed a funeral home website and on each page I want to display the names of the latest 5 deceased (which are in a MySQL db). Look at this page on the left column (where is says "latest obits." This is what i'm trying to do and don't know how to write the code. How can I achieve this?
FYI: To display ALL the obits under "Obituaries and Visitations", this is the code
<?php
include("connect_to_db.php");
?>
<?php
$query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext";
$query .= " FROM scales_obits ORDER BY deceased_date DESC";
$listings = mysql_query($query);
if (!listings) {
echo("<p>Error retrieving listings from lookup table<br>".
"Error: " . mysql_error());
exit();
}
echo("<table border=\"0\" width=\"88%\" class=\"obit\">");
while ($listing = mysql_fetch_array($listings)) {
$deceased_name = $listing["deceased_name"];
$deceased_date = $listing["datetext"];
$id = $listing["id"];
echo("<tr><td width=\"50%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>");
echo("<tr><td><strong>Died:</strong> ".$deceased_date."</td><td><a href=\"obitdetail.php?id=".$id."\">View Obituary</a></td></tr>");
echo("<tr><td colspan=\"2\"><br></td></tr>");
}
echo("</table>");
?>
_________________________________________
Any help is greatly appreciated!
FYI: To display ALL the obits under "Obituaries and Visitations", this is the code
<?php
include("connect_to_db.php");
?>
<?php
$query = "SELECT id, deceased_name, deceased_date, DATE_FORMAT(deceased_date, '%M %D, %Y') as datetext";
$query .= " FROM scales_obits ORDER BY deceased_date DESC";
$listings = mysql_query($query);
if (!listings) {
echo("<p>Error retrieving listings from lookup table<br>".
"Error: " . mysql_error());
exit();
}
echo("<table border=\"0\" width=\"88%\" class=\"obit\">");
while ($listing = mysql_fetch_array($listings)) {
$deceased_name = $listing["deceased_name"];
$deceased_date = $listing["datetext"];
$id = $listing["id"];
echo("<tr><td width=\"50%\"><a href=\"obitdetail.php?id=".$id."\"><strong>".$deceased_name."</strong></a></td><td> </td>");
echo("<tr><td><strong>Died:</strong> ".$deceased_date."</td><td><a href=\"obitdetail.php?id=".$id."\">View Obituary</a></td></tr>");
echo("<tr><td colspan=\"2\"><br></td></tr>");
}
echo("</table>");
?>
_________________________________________
Any help is greatly appreciated!