Forum Moderators: coopster
reviews.cnet.com/4504-5_7-0.html?id=30569389&id=20536585&id=30525842&id=30527150&tag=compare
I know how to display mysql result on a page, but this format presents major difficulty for someone with limited PHP knowledge like myself.
Could anyone shed light to this problem?
Thanks!
[edited by: jatar_k at 4:33 pm (utc) on Dec. 23, 2003]
[edit reason] shortened link for sidescroll [/edit]
$result = mysql_query("SELECT stuff FROM somewhere");
while ($row = mysql_fetch_array($result)) {
$product_name .= "<td>$row['product_name']</td>";
$release_date .= "<td>$row['release_date']</td>";
etc...
}
Then in the HTML:
<table>
<tr><td>Product Name</td><?=$product_name?></tr>
<tr><td>Release Date</td><?=$release_date?></tr>
etc...
</table>
//start a while loop to to create an array called $row for each record that $matches
while ($row = mysql_fetch_array($matches)) {
$id = $row['siteid'] ;
$ad_title = $row['sitetitle'] ;
$desc = $row['sitedescription'] ;
$short_desc = substr($desc, 0, 100) ;
//make a display block to display the results on a html table row at a time$display_block .= "
<tr>
<td width=\"25%\"><a href=\"http://$url/detail.php?annid=$id\"><strong>$ad_title</strong></a></td>
<td width=\"75%\">$short_desc ....<a href=\"http://$url/detail.php?annid=$id\"><em>read more</em></a></td>
</tr>" ;
} //close the while loop
// close the php and start a html table
?>
<table width="98%" border="1" align="center">
<tr>
<td width="23%"><strong>Title</strong></td>
<td width="77%"><strong>Description</strong></td>
</tr>
<? //open a php block to populate the table
echo "$display_block" ;
//close the php block and then the table
?>
</table>
HTH
Mark