From: Ali Asghar Toraby Parizy on
I agree with you. in this simple example we can use php but we may need
table with extra functionality and only client side scripts are reasonable
and applicable. we can create multi color and clickable rows by php but
we'll have greater server load.
anyway that was only an propose;-)

On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
<ash(a)ashleysheridan.co.uk>wrote:

> On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote:
>
> It isn't good idea to use php to visualize your table. You can fetch
> you data by php and style them by java script.
>
> On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
> <juan(a)rodriguezmonti.com.ar> wrote:
> > Hello Guys,
> > I would like to implement a two color row table for some queries that I'm doing.
> >
> > I use PHP to query a DB, then I use while to print all its results. I
> > have a code pretty similar to this one :
> >
> > $results = Here the QUERY;
> > echo "<html>";
> > echo "<head>";
> > echo '<link rel="stylesheet" type="text/css" href="style.css" />';
> > echo "</head>";
> > echo "<body>";
> > echo '<div id="container">';
> >
> > echo "<center><h2>Results</h2></center><br />";
> > echo ("<table border='1'>");
> > echo "<td><strong>At1</strong></td>
> > <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
> >
> > while ($row = while condition )) {
> > echo ("<tr>");
> > echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
> > <td>$row[3]</td><td>$row[4]</td> ";
> > echo "</div>";
> > echo "</body>";
> > echo "</html>";
> >
> > I just want to show you how I write the table. What I would like to
> > know is what do you suggest to do a two color row format.
> >
> > Thanks!,
> > Juan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
>
> Javascript is even less of a good idea, as it can be turned off and isn't
> available on all browsers. PHP doesn't rely on the clients browser, so is a
> safer bet.
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
From: Fernando on
What about this:

$color = "even";
while ($row = while condition )) {
$color = ($color == "even") ? "odd" : "even";
echo ("<tr class=\"$color\">");
echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td><td>$row[3]</td><td>$row[4]</td> ";
echo ("</tr>")
}

And have two classes in your style sheet that format each row differently.

Hope this helps.


On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
> I agree with you. in this simple example we can use php but we may need
> table with extra functionality and only client side scripts are reasonable
> and applicable. we can create multi color and clickable rows by php but
> we'll have greater server load.
> anyway that was only an propose;-)
>
> On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
> <ash(a)ashleysheridan.co.uk>wrote:
>
>
>> On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote:
>>
>> It isn't good idea to use php to visualize your table. You can fetch
>> you data by php and style them by java script.
>>
>> On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
>> <juan(a)rodriguezmonti.com.ar> wrote:
>>
>>> Hello Guys,
>>> I would like to implement a two color row table for some queries that I'm doing.
>>>
>>> I use PHP to query a DB, then I use while to print all its results. I
>>> have a code pretty similar to this one :
>>>
>>> $results = Here the QUERY;
>>> echo "<html>";
>>> echo "<head>";
>>> echo '<link rel="stylesheet" type="text/css" href="style.css" />';
>>> echo "</head>";
>>> echo "<body>";
>>> echo '<div id="container">';
>>>
>>> echo "<center><h2>Results</h2></center><br />";
>>> echo ("<table border='1'>");
>>> echo "<td><strong>At1</strong></td>
>>> <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
>>>
>>> while ($row = while condition )) {
>>> echo ("<tr>");
>>> echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
>>> <td>$row[3]</td><td>$row[4]</td> ";
>>> echo "</div>";
>>> echo "</body>";
>>> echo "</html>";
>>>
>>> I just want to show you how I write the table. What I would like to
>>> know is what do you suggest to do a two color row format.
>>>
>>> Thanks!,
>>> Juan
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>
>>
>> Javascript is even less of a good idea, as it can be turned off and isn't
>> available on all browsers. PHP doesn't rely on the clients browser, so is a
>> safer bet.
>>
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>
From: Ashley Sheridan on
On Wed, 2010-04-28 at 17:59 +0430, Ali Asghar Toraby Parizy wrote:

> I agree with you. in this simple example we can use php but we may
> need table with extra functionality and only client side scripts are
> reasonable and applicable. we can create multi color and clickable
> rows by php but we'll have greater server load.
> anyway that was only an propose;-)
>
>
> On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
> <ash(a)ashleysheridan.co.uk> wrote:
>
>
> On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy
> wrote:
>
> > It isn't good idea to use php to visualize your table. You can fetch
> > you data by php and style them by java script.
> >
> > On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
> > <juan(a)rodriguezmonti.com.ar> wrote:
> > > Hello Guys,
> > > I would like to implement a two color row table for some queries that I'm doing.
> > >
> > > I use PHP to query a DB, then I use while to print all its results. I
> > > have a code pretty similar to this one :
> > >
> > > $results = Here the QUERY;
> > > echo "<html>";
> > > echo "<head>";
> > > echo '<link rel="stylesheet" type="text/css" href="style.css" />';
> > > echo "</head>";
> > > echo "<body>";
> > > echo '<div id="container">';
> > >
> > > echo "<center><h2>Results</h2></center><br />";
> > > echo ("<table border='1'>");
> > > echo "<td><strong>At1</strong></td>
> > > <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
> > >
> > > while ($row = while condition )) {
> > > echo ("<tr>");
> > > echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
> > > <td>$row[3]</td><td>$row[4]</td> ";
> > > echo "</div>";
> > > echo "</body>";
> > > echo "</html>";
> > >
> > > I just want to show you how I write the table. What I would like to
> > > know is what do you suggest to do a two color row format.
> > >
> > > Thanks!,
> > > Juan
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
>
>
>
>
> Javascript is even less of a good idea, as it can be turned
> off and isn't available on all browsers. PHP doesn't rely on
> the clients browser, so is a safer bet.
>
>
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>
>


I just feel it's often a false economy. Relying too heavily on
Javascript for something that can be achieved with a little work on the
server is not good. I'm a big supporter of accessibility, and for me,
using Javascript to provide essential functionality is best avoided. I
agree that some things cannot be done (imagine if Google Docs tried not
using Javascript!) It's a topic that has come up now and again on the
list.

For the best results build the site so that all the raw functionality is
there, and then use Javascript after to enhance that. So you could
create a site that has all its contents output by PHP and navigates
using standard links, then have Javascript that re-writes the links to
make Ajax calls. Turn off Javascript and everything will still work, but
turn it on, and suddenly things work a bit better. No functionality is
lost, it's just been changed slightly.

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Ashley Sheridan on
On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote:

> What about this:
>
> $color = "even";
> while ($row = while condition )) {
> $color = ($color == "even") ? "odd" : "even";
> echo ("<tr class=\"$color\">");
> echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td><td>$row[3]</td><td>$row[4]</td> ";
> echo ("</tr>")
> }
>
> And have two classes in your style sheet that format each row differently.
>
> Hope this helps.
>
>
> On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
> > I agree with you. in this simple example we can use php but we may need
> > table with extra functionality and only client side scripts are reasonable
> > and applicable. we can create multi color and clickable rows by php but
> > we'll have greater server load.
> > anyway that was only an propose;-)
> >
> > On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
> > <ash(a)ashleysheridan.co.uk>wrote:
> >
> >
> >> On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote:
> >>
> >> It isn't good idea to use php to visualize your table. You can fetch
> >> you data by php and style them by java script.
> >>
> >> On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
> >> <juan(a)rodriguezmonti.com.ar> wrote:
> >>
> >>> Hello Guys,
> >>> I would like to implement a two color row table for some queries that I'm doing.
> >>>
> >>> I use PHP to query a DB, then I use while to print all its results. I
> >>> have a code pretty similar to this one :
> >>>
> >>> $results = Here the QUERY;
> >>> echo "<html>";
> >>> echo "<head>";
> >>> echo '<link rel="stylesheet" type="text/css" href="style.css" />';
> >>> echo "</head>";
> >>> echo "<body>";
> >>> echo '<div id="container">';
> >>>
> >>> echo "<center><h2>Results</h2></center><br />";
> >>> echo ("<table border='1'>");
> >>> echo "<td><strong>At1</strong></td>
> >>> <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
> >>>
> >>> while ($row = while condition )) {
> >>> echo ("<tr>");
> >>> echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
> >>> <td>$row[3]</td><td>$row[4]</td> ";
> >>> echo "</div>";
> >>> echo "</body>";
> >>> echo "</html>";
> >>>
> >>> I just want to show you how I write the table. What I would like to
> >>> know is what do you suggest to do a two color row format.
> >>>
> >>> Thanks!,
> >>> Juan
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>>
> >>
> >>
> >> Javascript is even less of a good idea, as it can be turned off and isn't
> >> available on all browsers. PHP doesn't rely on the clients browser, so is a
> >> safer bet.
> >>
> >>
> >> Thanks,
> >> Ash
> >> http://www.ashleysheridan.co.uk
> >>
> >>
> >>
> >>
> >


You really only need one alternate row class, as I showed in my earlier
example. All the rows are styled using the tables default CSS, and then
you just style the rows you want to change from that default. Here it is
again :p

http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php

Thanks,
Ash
http://www.ashleysheridan.co.uk


From: Fernando on
But then you need to differentiate the table, otherwise all your tables
will have the same row formating no? This way you only apply the
formating to those rows that need it.

Fernando.

On 28/04/2010 09:35, Ashley Sheridan wrote:
> On Wed, 2010-04-28 at 09:34 -0400, Fernando wrote:
>
>
>> What about this:
>>
>> $color = "even";
>> while ($row = while condition )) {
>> $color = ($color == "even") ? "odd" : "even";
>> echo ("<tr class=\"$color\">");
>> echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td><td>$row[3]</td><td>$row[4]</td> ";
>> echo ("</tr>")
>> }
>>
>> And have two classes in your style sheet that format each row differently.
>>
>> Hope this helps.
>>
>>
>> On 28/04/2010 09:29, Ali Asghar Toraby Parizy wrote:
>>
>>> I agree with you. in this simple example we can use php but we may need
>>> table with extra functionality and only client side scripts are reasonable
>>> and applicable. we can create multi color and clickable rows by php but
>>> we'll have greater server load.
>>> anyway that was only an propose;-)
>>>
>>> On Wed, Apr 28, 2010 at 4:12 PM, Ashley Sheridan
>>> <ash(a)ashleysheridan.co.uk>wrote:
>>>
>>>
>>>
>>>> On Wed, 2010-04-28 at 16:16 +0430, Ali Asghar Toraby Parizy wrote:
>>>>
>>>> It isn't good idea to use php to visualize your table. You can fetch
>>>> you data by php and style them by java script.
>>>>
>>>> On Wed, Apr 28, 2010 at 3:59 PM, Juan Rodriguez Monti
>>>> <juan(a)rodriguezmonti.com.ar> wrote:
>>>>
>>>>
>>>>> Hello Guys,
>>>>> I would like to implement a two color row table for some queries that I'm doing.
>>>>>
>>>>> I use PHP to query a DB, then I use while to print all its results. I
>>>>> have a code pretty similar to this one :
>>>>>
>>>>> $results = Here the QUERY;
>>>>> echo "<html>";
>>>>> echo "<head>";
>>>>> echo '<link rel="stylesheet" type="text/css" href="style.css" />';
>>>>> echo "</head>";
>>>>> echo "<body>";
>>>>> echo '<div id="container">';
>>>>>
>>>>> echo "<center><h2>Results</h2></center><br />";
>>>>> echo ("<table border='1'>");
>>>>> echo "<td><strong>At1</strong></td>
>>>>> <td><strong>At2</strong></td> <td><strong>At3</strong></td> $
>>>>>
>>>>> while ($row = while condition )) {
>>>>> echo ("<tr>");
>>>>> echo "<td>$row[0]</td><td>$row[1]</td> <td>$row[2]</td>
>>>>> <td>$row[3]</td><td>$row[4]</td> ";
>>>>> echo "</div>";
>>>>> echo "</body>";
>>>>> echo "</html>";
>>>>>
>>>>> I just want to show you how I write the table. What I would like to
>>>>> know is what do you suggest to do a two color row format.
>>>>>
>>>>> Thanks!,
>>>>> Juan
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>> Javascript is even less of a good idea, as it can be turned off and isn't
>>>> available on all browsers. PHP doesn't rely on the clients browser, so is a
>>>> safer bet.
>>>>
>>>>
>>>> Thanks,
>>>> Ash
>>>> http://www.ashleysheridan.co.uk
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>
> You really only need one alternate row class, as I showed in my earlier
> example. All the rows are styled using the tables default CSS, and then
> you just style the rows you want to change from that default. Here it is
> again :p
>
> http://www.ashleysheridan.co.uk/coding_php_alternate_rows.php
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
>
>