Hi PHPers,
the following function is supposed to build an html table, creating a
content row for every row in a database table. It is creating a table with
the correct number of rows, but NO content is being echoed...
I think I must be using the extract() function inside the for loop wrong...
any pointers?
tia!
jaxon
<?php
function news_box($max)
{
include_once("inc/config.inc");
include_once("inc/db_connect_params.inc");
$link_id = mysql_connect($host, $usr, $pass);
mysql_select_db($database, $link_id); //select database catalog
echo "<table border=\"0\" cellpadding=\"0\" cellspacing=\"2\"
width=\"165\">";
if (!isset($max)) $max=5; //upper limit of news boxes to build
for ($i = 1; $i <= $max; $i++)
{
$sql="select i.nID, i.date, i.headline, i.subtitle, i.blurb from
news_items i, news_box b where i.nID = b.nID and b.dID = $i";
$result = mysql_query($sql, $link_id);
$row = mysql_fetch_row($result);
extract($row); //the variables below match field names in this row
echo "
<tr><td><h1>$headline</h1></td></tr>
<tr><td><h4>$subtitle</h4></td></tr>
<tr><td align=\"right\"><h6>$date</h6></td></tr>
<tr><td>$blurb</td></tr>
<tr><td><a href=\"news.php?#$nID\"><h5>...more</h5></a></td></tr>
";
echo "</table>";
}
}
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]