Table Output Question

Table Output Question

am 15.11.2005 00:37:36 von Jeff Grossman

I have a table, where each line is the output of a query from a MySQL
database. I do not use borders, so the page is a little difficult to
read sometimes. Is it possible, or how do I, alternate the background
color of each row when I output it?

My code is like this:

while (query) {



}

I am not sure how to output two rows in the same while loop.

Thanks for any help you can offer me.

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

Re: Table Output Question

am 15.11.2005 01:21:35 von Micah Stevens

You don't have to output two rows.. just do this:

$color = "red"; // init first color.
while ($row = mysql_fetch_assoc($data)) {
if ($color == "red") {
$color = "blue";
} else {
$color = "red";
}
?>
..................

}

-Micah

On Monday 14 November 2005 3:37 pm, Jeff Grossman wrote:
> I have a table, where each line is the output of a query from a MySQL
> database. I do not use borders, so the page is a little difficult to
> read sometimes. Is it possible, or how do I, alternate the background
> color of each row when I output it?
>
> My code is like this:
>
> while (query) {
>
>
>
> }
>
> I am not sure how to output two rows in the same while loop.
>
> Thanks for any help you can offer me.

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

RE: Table Output Question

am 15.11.2005 02:15:44 von Bastien Koert


$row1 = "FFFFFF";
$row2 = "AAAAAA";
$counter = 0;

while ($rows = mysql_fetch_array($result))
{
$color = ($counter % 2 ==0) ? $row1 : $row2 ;

echo "...";

}


bastien


ps: a class css definition would be better here



>From: Jeff Grossman
>To: php-db@lists.php.net
>Subject: [PHP-DB] Table Output Question
>Date: Mon, 14 Nov 2005 15:37:36 -0800
>
>I have a table, where each line is the output of a query from a MySQL
>database. I do not use borders, so the page is a little difficult to
>read sometimes. Is it possible, or how do I, alternate the background
>color of each row when I output it?
>
>My code is like this:
>
>while (query) {
>
>
>
>}
>
>I am not sure how to output two rows in the same while loop.
>
>Thanks for any help you can offer me.
>
>--
>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: Table Output Question

am 15.11.2005 02:25:02 von Ajree

Take a look at this article on ALA:
http://www.alistapart.com/articles/zebratables/

It makes markup more elegant than repeated .

--
Ajree

Jeff Grossman wrote:
> I have a table, where each line is the output of a query from a MySQL
> database. I do not use borders, so the page is a little difficult to
> read sometimes. Is it possible, or how do I, alternate the background
> color of each row when I output it?
>
> My code is like this:
>
> while (query) {
>
>
>
> }
>
> I am not sure how to output two rows in the same while loop.
>
> Thanks for any help you can offer me.

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

Re: Re: Table Output Question

am 15.11.2005 02:48:49 von Micah Stevens

I don't see what's more elegant about. They have a good point that you only
need to do one out of the two, but doing it in Javascript versus PHP only has
the advantage that it puts the processing load for that on the client
computer.

Am I missing something?

On Monday 14 November 2005 5:25 pm, Ajree wrote:
> Take a look at this article on ALA:
> http://www.alistapart.com/articles/zebratables/
>
> It makes markup more elegant than repeated .
>
> --
> Ajree
>
> Jeff Grossman wrote:
> > I have a table, where each line is the output of a query from a MySQL
> > database. I do not use borders, so the page is a little difficult to
> > read sometimes. Is it possible, or how do I, alternate the background
> > color of each row when I output it?
> >
> > My code is like this:
> >
> > while (query) {
> >
> >
> >
> > }
> >
> > I am not sure how to output two rows in the same while loop.
> >
> > Thanks for any help you can offer me.

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

Re: Re: Table Output Question

am 15.11.2005 03:12:24 von Ajree

Micah Stevens wrote:
> I don't see what's more elegant about. They have a good point that you only
> need to do one out of the two, but doing it in Javascript versus PHP only has
> the advantage that it puts the processing load for that on the client
> computer.
>
> Am I missing something?

The second advantage is being more web standards compliant. Taking
presentation out of the markup (clean table structure instead of
attributes mess). But it's not the place for this (non-php) discussion,
I just wanted to show another solution. 'More elegant' is only my
opinion and I didn't want to offend anyone :)

Best regards,
Ajree

>
> On Monday 14 November 2005 5:25 pm, Ajree wrote:
>
>>Take a look at this article on ALA:
>>http://www.alistapart.com/articles/zebratables/
>>
>>It makes markup more elegant than repeated .
>>
>>--
>>Ajree
>>
>>Jeff Grossman wrote:
>>
>>>I have a table, where each line is the output of a query from a MySQL
>>>database. I do not use borders, so the page is a little difficult to
>>>read sometimes. Is it possible, or how do I, alternate the background
>>>color of each row when I output it?
>>>
>>>My code is like this:
>>>
>>>while (query) {
>>>
>>>
>>>
>>>}
>>>
>>>I am not sure how to output two rows in the same while loop.
>>>
>>>Thanks for any help you can offer me.

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

Re: Re: Table Output Question

am 15.11.2005 03:25:51 von Micah Stevens

Sorry if I sounded offended, I'm not. I was just curious because the advantage
wasn't obvious to me. I see your point now though. Thanks for the insight.

On Monday 14 November 2005 6:12 pm, Ajree wrote:
> Micah Stevens wrote:
> > I don't see what's more elegant about. They have a good point that you
> > only need to do one out of the two, but doing it in Javascript versus PHP
> > only has the advantage that it puts the processing load for that on the
> > client computer.
> >
> > Am I missing something?
>
> The second advantage is being more web standards compliant. Taking
> presentation out of the markup (clean table structure instead of
> attributes mess). But it's not the place for this (non-php) discussion,
> I just wanted to show another solution. 'More elegant' is only my
> opinion and I didn't want to offend anyone :)
>
> Best regards,
> Ajree
>
> > On Monday 14 November 2005 5:25 pm, Ajree wrote:
> >>Take a look at this article on ALA:
> >>http://www.alistapart.com/articles/zebratables/
> >>
> >>It makes markup more elegant than repeated .
> >>
> >>--
> >>Ajree
> >>
> >>Jeff Grossman wrote:
> >>>I have a table, where each line is the output of a query from a MySQL
> >>>database. I do not use borders, so the page is a little difficult to
> >>>read sometimes. Is it possible, or how do I, alternate the background
> >>>color of each row when I output it?
> >>>
> >>>My code is like this:
> >>>
> >>>while (query) {
> >>>
> >>>
> >>>
> >>>}
> >>>
> >>>I am not sure how to output two rows in the same while loop.
> >>>
> >>>Thanks for any help you can offer me.

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

Re: Table Output Question

am 15.11.2005 03:26:36 von Jeff Grossman

Micah Stevens wrote:
>
> You don't have to output two rows.. just do this:
>
> $color = "red"; // init first color.
> while ($row = mysql_fetch_assoc($data)) {
> if ($color == "red") {
> $color = "blue";
> } else {
> $color = "red";
> }
> ?>
> ..................
>
> > }
>
> -Micah

Great, thanks for the help and information. May I ask, how does PHP
know to change the color? What do the "?"'s do in ""?

Thanks for the help.

Jeff

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

Re: Table Output Question

am 15.11.2005 03:27:44 von Jeff Grossman

Bastien Koert wrote:
> >
> $row1 = "FFFFFF";
> $row2 = "AAAAAA";
> $counter = 0;
>
> while ($rows = mysql_fetch_array($result))
> {
> $color = ($counter % 2 ==0) ? $row1 : $row2 ;
>
> echo "...";
>
> }
>
>
> bastien
>
>
> ps: a class css definition would be better here

Thanks for the help. After reading a couple of the responses, I
couldn't believe that I did not think of this. I don't know a lot about
CSS yet (just purchased a book). But, could you share with me about the
ps line?

Thanks again for you help.

Jeff

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

Re: Re: Table Output Question

am 15.11.2005 03:39:45 von Micah Stevens

Sorry, that's shorthand.. is the same as:



is the end tag..

On Monday 14 November 2005 6:26 pm, Jeff Grossman wrote:
> Micah Stevens wrote:
> > You don't have to output two rows.. just do this:
> >
> > $color = "red"; // init first color.
> > while ($row = mysql_fetch_assoc($data)) {
> > if ($color == "red") {
> > $color = "blue";
> > } else {
> > $color = "red";
> > }
> > ?>
> > ..................
> >
> > > > }
> >
> > -Micah
>
> Great, thanks for the help and information. May I ask, how does PHP
> know to change the color? What do the "?"'s do in ""?
>
> Thanks for the help.
>
> Jeff

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

RE: Re: Table Output Question

am 15.11.2005 05:47:18 von Bastien Koert

Simply put, you create a couple of css classes that make the row look the
way you want and then

while ($rows = mysql_fetch_array($result))
{
$color = ($counter % 2 ==0) ? "rowclass1" : "rowclass2" ;

echo "...";

}

Its essentially the same thing, just neater and lets you concentrate on the
code for the table without the worry about the way the row looks

Bastien

>From: Jeff Grossman
>To: php-db@lists.php.net
>Subject: [PHP-DB] Re: Table Output Question
>Date: Mon, 14 Nov 2005 18:27:44 -0800
>
>Bastien Koert wrote:
> > > >
> > $row1 = "FFFFFF";
> > $row2 = "AAAAAA";
> > $counter = 0;
> >
> > while ($rows = mysql_fetch_array($result))
> > {
> > $color = ($counter % 2 ==0) ? $row1 : $row2 ;
> >
> > echo "...";
> >
> > }
> >
> >
> > bastien
> >
> >
> > ps: a class css definition would be better here
>
>Thanks for the help. After reading a couple of the responses, I
>couldn't believe that I did not think of this. I don't know a lot about
>CSS yet (just purchased a book). But, could you share with me about the
>ps line?
>
>Thanks again for you help.
>
>Jeff
>
>--
>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: Table Output Question

am 15.11.2005 18:52:16 von Jeff Grossman

Bastien Koert wrote:
> Simply put, you create a couple of css classes that make the row look the
> way you want and then
>
> while ($rows = mysql_fetch_array($result))
> {
> $color = ($counter % 2 ==0) ? "rowclass1" : "rowclass2" ;
>
> echo "...";
>
> }
>
> Its essentially the same thing, just neater and lets you concentrate on the
> code for the table without the worry about the way the row looks
>
> Bastien
>
Thanks again for the information.

Jeff

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

Bug #33877 When multiple result sets are not freed subsequent queries fail

am 15.11.2005 20:10:07 von Harold Chung

I have been trying to follow the possible workaround that the bug report has
suggested, to use mssql_free_result at the end of PHP pages to free up
resources. However, it does not seem to solve the problem.

http://bugs.php.net/bug.php?id=33877

Has anyone encountered this problem? Any help would be greatly appreciated.

Cheers,
Harold.

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