PDA

View Full Version : styling php results


dazzclub
04-16-2007, 03:58 PM
okay ive managed to retrieve some data from my database using the code below



<?php
$db = mysql_connect("localhost", "root", "");
mysql_select_db("colourchange",$db);
$result = mysql_query("SELECT * FROM game",$db);

while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["name"];
echo " <br />";
}
echo "</TABLE>";
?>



where would i go in regards to be inserting in a class tag to style the "name results"

davidj
04-16-2007, 07:15 PM
where you have...
while($myrow = mysql_fetch_array($result))
{
echo "<TR><TD>";
echo $myrow["name"];
echo " <br />";
}
echo"</TABLE>";
?>

try it this way...

$data = "<table>";
while($myrow = mysql_fetch_array($result))
{
$data .= "<TR class=/"thisclass/"><TD>$myrow["name"];</td></tr>";
}
$data .="</TABLE>";
?>


then just echo $data where you want the table displayed


note the class call