View Full Version : Which tools do I need
johnp
03-30-2008, 04:32 PM
I have created my web site is a Wysiwyg program. I want to include some formatable, dynamic tables from my database but am not sure were to start. I am okay with getting the data with php, just what to use to output in a formatted structure? Can you recommend a go place to start.
Thanks,
John
TheWebHostingHero
03-30-2008, 08:47 PM
Supposing your database connection is already established:
<?php
$sql = "select * from mytable";
$result = mysql_query($sql);
$class = "Row";
$html = '<table width="100%" cellspacing="1" cellpadding="3">';
while($row = mysql_fetch_array($result))
{
$html .= "\n<tr class=\"$class\">";
$html .= "\n<td>" . $row['column1'] . "</td>";
$html .= "<td>" . $row['column2'] . "</td>";
$html .= "\n</tr>";
if($class == "row") $class = "AltRow"
else $class = "Row";
}
$html . = "</table>";
echo $html;
?>
So this way you can use CSS to alternate the row colors.
Is that the sort of stuff you wanted to know?
johnp
03-31-2008, 04:13 PM
That is what I am looking for. The trouble I am having is understanding how does it know where to position the table on the page?
Thanks,
John
felgall
03-31-2008, 04:50 PM
All the page layout of where things are put should be handled by stylesheet commands
johnp
04-01-2008, 03:18 AM
The table works great, I am still having trouble with the formatting.
Can you give me an example of the style code for above code where AltRow=Cyan and Row = White with font-style Arial.
I have tried using <style type="text/css"> but have not had any success with class statement.
Thank you very much
felgall
04-01-2008, 12:53 PM
.Row {background-color:white; font-family: arial;}
.AltRow {background-color:cyan; font-family: arial;}
TheWebHostingHero
04-02-2008, 08:02 AM
And add this to your webpage's header to attach an external style sheet:
<link rel="stylesheet" href="/path/to/style.css" type="text/css" />
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.