ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-db
php-db
RE: [PHP-DB] SELECT & html
by Robbert van Andel other posts by this author
Dec 4 2005 11:23AM messages near this date
Re: [PHP-DB] SELECT & html
| [PHP-DB] 1
There's a couple of ways to do this.  For the row color you would set that
as you looped through the returned rows.  Using the pear db class:

$count = 0;
echo "<table> \n";
while($db-> fetchInto($data)) {
	$count++;
	if($count % 2 == 0) {
		$bgColor = "background-color:#dcdcdc";
	}
	else {
		$bgColor = "background-color:transparent";
	}
	echo "<tr style='$dgColor'> \n";
	foreach($data as value) {
		echo "<td> " . htmlentities($value) . "</td>\n";
	}
	echo "</tr> \n";
}

As for the limiting of rows, you would use the limit statement (assuming
you're using a DBMS that supports it).

Hopefully this helps,
Robbert van Andel

-----Original Message-----
From: Ron Piggott (PHP) [mailto:ron.php@[...].org] 
Sent: Sunday, December 04, 2005 10:39 AM
To: PHP DB
Subject: [PHP-DB] SELECT & html <table> 

I have two questions.  

I would like to display the contents of my table with the first row
being grey in background and the next row being white and the third row
being grey, fourth being white, etc.  I am not sure how to do this.

Secondly I only want the first 20 records to be displayed at a time and
then I want to create a "NEXT" link for the next 20 records (21-40) ...
any idea how you would use the SELECT command to do this?

Ron

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Thread:
Ron Piggott
El Bekko
Amol Hatwar
Robbert van Andel

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved