SELECT & html <table>

SELECT & html <table>

am 04.12.2005 19:38:58 von Ron Piggott

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

RE: SELECT & html <table>

am 04.12.2005 20:22:35 von Robbert van Andel

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 "

\n";
while($db->fetchInto($data)) {
$count++;
if($count % 2 == 0) {
$bgColor = "background-color:#dcdcdc";
}
else {
$bgColor = "background-color:transparent";
}
echo "\n";
foreach($data as value) {
echo "\n";
}
echo "\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@actsministries.org]
Sent: Sunday, December 04, 2005 10:39 AM
To: PHP DB
Subject: [PHP-DB] SELECT & html
" . htmlentities($value) . "


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

Re: SELECT & html <table>

am 05.12.2005 06:04:02 von jusa_98

--0-442914143-1133759042=:11918
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

From: "Ron Piggott (PHP)" To: "PHP DB" Date: Sun, 04 Dec 2005 13:38:58 -0500 Subject: SELECT & html




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
[input] [input] [input] [input] [input] [input] [input] [input]


Visit http://www.mysql.com/ and read a little bit about LIMIT command. :)

Jerry


---------------------------------
Do you Yahoo!?
Take your Mail with you - get Yahoo! Mail on your mobile

---------------------------------
Do you Yahoo!?
Never miss an Instant Message - Yahoo! Messenger for SMS
--0-442914143-1133759042=:11918--

Re: SELECT & html <table>

am 05.12.2005 13:21:37 von Amol Hatwar

On Sun, 2005-12-04 at 13:38 -0500, Ron Piggott (PHP) wrote:
> 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.

Cool. You must use CSS for this. Your PHP must dish out

tags with
alternating CSS classes... this allows you to change colors later
without editing code. This done, now for dishing out tag with
alternating classes you can use a function built along the following
lines:

function showRow() {
static $row = 1;
print(" Your HTML Row goes here. ");

if (2 == $row) {
$row--;
}
else {
$row++;
}
}

>
> 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?

This should be plain simple... Try reading more about SELECT. You need
to use the LIMIT clause with SELECT.

Have fun,

ah

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

Re: SELECT & html <table>

am 05.12.2005 18:10:04 von El Bekko

Ron Piggott (PHP) wrote:
> 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.

Well, that's pretty easy to do actually :P
You have your while() statement to execute your displaying part. In
there, you add some if()'s

I'll use an example for 20 posts. An example:

$array1 = array(1,3,5,7,9,11,13,15,17,19)

while($i < $totalrows)
{
$j = $i - 1;
if($i == array1[$j])
{
--some code--
echo "all the rest";
}
else
{
--some code--
echo "all the rest";
}
--more code--
}
?>

This is a really easy way to do it, and I guess it works :)

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