Forums
This topic is locked
Why is this displaying the same data in all?
Posted 10 Aug 2007 20:42:53
1
has voted
10 Aug 2007 20:42:53 daniel Gage posted:
Can anyone help me on this? Why is the following code showing only the first record in the query 14 times? Instead of displaying them all? Any help is appreciated.
$query_newsitems = "SELECT * FROM csprojects WHERE coreproject = 'cplan' ORDER BY 'id' DESC";
$newsitems = mysql_query($query_newsitems) or die(mysql_error());
$row_newsitems = mysql_fetch_assoc($newsitems);
$totalRows_newsitems = mysql_num_rows($newsitems);
$query_cat = "SELECT * FROM csprojects WHERE coreproject = 'cplan' ORDER BY 'id' DESC ";
$picture= "<a href=\"" . $row_newsitems['link'] . "\" target=\"_blank\">" . "<img src=\"" . $row_newsitems['picture'] . "\" target=\"blank\"" . "\" border=\"0\" >" . "</a>\n";
$title= "<a href=\"" . $row_newsitems['link'] . "\" target=\"_blank\">" . $row_newsitems['title'] . "</a>\n";
$cat = mysql_query($query_newsitems, $BioWeb) or die(mysql_error());
$total = mysql_num_rows($newsitems);
while($row = mysql_fetch_array($newsitems))
{
$items[] = array(1 => $row=$picture, 2 => $row=$title, 3 => $row=$row_newsitems['blurb'] . "</p>\n"
}
$numcols = 3;
$numitems = count($items);
$numrows = ceil($numitems/$numcols);
echo '<table width="470">';
for ($row=1; $row <= $numrows; $row++)
{
$cell = 0;
echo ' <tr>'."\n";
for ($col=1; $col <= $numcols; $col++)
{
echo ' <td width="'.round(100/$numcols).'%">'."\n";
if ($col===1)
{
$cell += $row;
echo '<table cellpadding=".1" cellspacing="0" border="0"><tr><td valign="top" align="right" width="30%">';
print $items[$cell - 1][1]; /* $items[$cell - 1][1] to display title $items[$cell - 1][2] etc... */
echo '</td>';
echo '<td valign="top">';
print $items[$cell - 1][2];
echo '<br>';
print $items[$cell - 1][3];
echo '</tr></table><br>';
}
else {
$cell += $numrows;
echo '<table cellpadding=".1" cellspacing="0" border="0"><tr><td valign="top" align="right" width="30%">';
print $items[$cell - 1][1];
echo '</td>';
echo '<td valign="top">';
print $items[$cell - 1][2];
echo '<br>';
print $items[$cell - 1][3];
echo '</tr></table><br>';
}
echo ' </td>'."\n";
}
echo ' </tr>'."\n";
}
echo '</table>';
?>