Hi again guys,

I am getting information from a table that I would dearly love to format using my css styles in an external css sheet. Now I am calling the sheet in the header correctly, tested that to make sure.

Here is the code I am using. This generates the text, but not formatted according to my css style sheet.

echo "<div align=\"left\">"; 
while($row=mysql_fetch_array($result))
{ 
echo "<p class=\"index_page_big\">";
echo $row['manufacturer']." ".$row['make']." ".$row['model']." ".$row['variant'];
echo "</p>";
}
mysql_close($connect);
?>
</div>

What I would ideally like to do, is have lines 4,5,6 all one one line. But can just as well live with the three lines if just for the sake of readability! Nice to have short precise code, but then also good to be able to read what has been done easily!

Recommended Answers

All 2 Replies

Dont knowe if this helps, but i usually write my html within php with ' rather than ".
example,

echo "<li style='color:red;'>hello world</li>";

another little thing i do is use arrays to get my records, can sometimes keep coding efforts down. example,

echo "<div align='left'>";
while($row=mysql_fetch_array($result))
{
$columns = array("manufacturer", "make", "model", "variant");
foreach($columns as $cname){$$cname = $row[$cname];}
echo "<p class='index_page_big'>$manufacturer $make $model $variant</p>";
}
mysql_close($connect);

Thanks gotboots

Done and dusted now. Like your idea of

$columns = array("manufacturer", "make", "model", "variant");
foreach($columns as $cname){$$cname = $row[$cname];}

Makes life just that little bit easier.

Carter

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.