Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Spreadsheet output looklike in PHP

Status
Not open for further replies.

dkin

Programmer
Dec 11, 2002
39
0
0
ES
Hi,

This script generates a MySQL output, how can I had lines between each field and how can I create a “box” (horizontal and vertical lines) around each records so I will have separation.

Thanks.

Script:

if ($rowsFound > 0)
{
while ($row = @ mysql_fetch_array($result))
{
if (isset($_GET[$row["ID"]])=='yes')
{
echo '<tr><td><b>'.'Driver: '. '</tr></td></b>'. $row[&quot;Driver&quot;].&quot;<br><br>\n&quot;;
echo '<tr><td><b>'.' Speed: '. '</tr></td></b>'. $row[&quot;Speed&quot;]. &quot;<br><br>\n&quot;;
echo '<tr><td><b>'.'Nome: '. '</tr></td></b>'. $row[&quot;Nome&quot;]. &quot;<br><br>\n&quot;;
echo &quot;<br><br>\n&quot;;
}
}
}
 
You could use CSS to add borders and style it a bit more spreadsheet-like.
Heres an example I &quot;borrowed&quot; and reworked from a site I worked on previously:
Code:
<!doctype html public &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;>
<html>
<head>
<style>
.displayTable{
	margin-top:10px;
	background:#bbbbbb;
	width:90%;
	border-right:1px solid #555555;
	border-bottom:1px solid #555555;
	font-size:13px;
	}
.displayTable td{
	background:#f3f3f3;
	padding-left:5px;
	padding-right:5px;
	border-right:1px solid #bbbbbb;
	border-bottom:1px solid #bbbbbb;	
	text-align:Center;
}
.displayTable td .inputEntry{
	border:0px;
	width:100%;
	margin:0px;
}
.displayTable .columnHeader{
	background:#bbbbbb;
	border-top:1px solid #eeeeee;
	border-left:1px solid #eeeeee;
	border-right:1px solid #555555;
	border-bottom:1px solid #555555;
	margin:0px;
	text-align:center;
	font-size:14px;
	text-align:center;
}
</style>
</head>
<body>
<table class=&quot;displayTable&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
	<tr>
		<td class=&quot;columnHeader&quot;>&nbsp;</td>
		<td class=&quot;columnHeader&quot;>A</td>
		<td class=&quot;columnHeader&quot;>B</td>
		<td class=&quot;columnHeader&quot;>C</td>
		<td class=&quot;columnHeader&quot;>D</td>
	</tr>
	<tr>
		<td class=&quot;columnHeader&quot;>&nbsp;</td>
		<td>something here</td>
		<td>something else here</td>
		<td>something here</td>
		<td>something else here</td>
	</tr>
	<tr>
		<td class=&quot;columnHeader&quot;>&nbsp;</td>
		<td><input type=&quot;text&quot; value=&quot;an input&quot; class=&quot;inputEntry&quot;></td>
		<td><input type=&quot;text&quot; value=&quot;an input&quot; class=&quot;inputEntry&quot;></td>
		<td><input type=&quot;text&quot; value=&quot;an input&quot; class=&quot;inputEntry&quot;></td>
		<td><input type=&quot;text&quot; value=&quot;an input&quot; class=&quot;inputEntry&quot;></td>
	</tr>
</table>
</body>
</html>

Basically all you need to do is define classes for your cells and table (I also did inputs) and then use those classes in you tags. It would be possible to just redefince the generic look for all of your tables, th, and td tags, but that can lead to troubles down the road if you have another table on the page that you don't want to look spreadsheetish.

Hope this helps,
-Tarwn ________________________________________________________________________________
Want to get great answers to your Tek-Tips questions? Have a look at faq333-2924
 
Is there a simple way to do it, not with CSS.
 
use cellpadding in ur table

<table border=&quot;1&quot; cellspacing=&quot;1&quot; cellpadding=&quot;1&quot;>
ur code to retrieve record here..
there is no need to put <br> inside ur table.
<? if ($rowsFound > 0)
{
while ($row = @ mysql_fetch_array($result))
{
if (isset($_GET[$row[&quot;ID&quot;]])=='yes')
{
echo '<tr><td><b>'.'Driver: '. '</b></td><td>'. $row[&quot;Driver&quot;].&quot;</td></tr>&quot;;
echo '<tr><td><b>'.' Speed: '. '</b></td><td>'. $row[&quot;Speed&quot;]. &quot;</td></tr>&quot;;
echo '<tr><td><b>'.'Nome: '. '</b></td><td>'. $row[&quot;Nome&quot;]. &quot;</td></tr>&quot;;
}
}
}
?>
</table>

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Try embedding tables. You can create a single cell table with a black background/fill. You can then place another table inside of that single-cell table. The inner table will include your data. Fill all cells in the inner table with white and set the cell spacing to 1 pixel.

<table border=&quot;0&quot; cellpadding=&quot;1&quot; cellspacing=&quot;0&quot; bgcolor=&quot;black&quot;>
<tr>
<td>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;1&quot; width=&quot;180&quot;>
<tr>
<td bgcolor=&quot;white&quot;></td>
<td bgcolor=&quot;white&quot;>A</td>
<td bgcolor=&quot;white&quot;>B</td>
</tr>
<tr>
<td bgcolor=&quot;white&quot;>1</td>
<td bgcolor=&quot;white&quot;></td>
<td bgcolor=&quot;white&quot;></td>
</tr>
<tr>
<td bgcolor=&quot;white&quot;>2</td>
<td bgcolor=&quot;white&quot;></td>
<td bgcolor=&quot;white&quot;></td>
</tr>
</table>
</td>
</tr>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top