[PHP-DB] RE: TO TIM FOSTER - REGARDING THE ALTERNATING ROWS PULLED FROM TABLES

2001-12-04 Thread Tim Foster

Thanks for the response.

I too have been a programmer for about  years. (sorry, I couldn't resist ;)

I forgot all about testing my approach on PHP, so I went ahead and gave it a shot 
today. I
don't remember what I posted in my pseudocode, but I only encountered a minor syntax 
error
when I wrote it off the top of my head. I'm not sure what problems you saw earler, but
here's what I came up with today (it works on my WinNT development box):





  
row , cell 1
row , cell 2
row , cell 3
  





This prints out a table that's 3 colums wide and 10 rows high, with each row 
alternating
colors between green and white. There are a couple of reasons I offered this approach:
1. Speed. It doesnt repeatedly use a function inside the loop to determine the current
color. I would think this would be desireable. I'm betting/guessing that calling a
function then comparing it to a value then sticking it in an array is slower than
accessing an element of an array using %.
2. Flexibility. If you need more than 2 colors, you just expand the array and change 
the
modulus number from 2 to however many colors you want.

I'm still fairly new to all things *nix, so my handling of regular expressions is 
simply
not what it should be. When I look at the ereg() you've got... I'm scratching my head.
(but I *think* I know what you're doing).

TIM
-Depression is merely anger without enthusiasm.


> -Original Message-
> From: Vins [mailto:[EMAIL PROTECTED]]
> Sent: Monday, December 03, 2001 3:27 PM
> To: [EMAIL PROTECTED]
> Subject: TO TIM FOSTER - REGARDING THE ALTERNATING ROWS PULLED FROM
> TABLES
>
>
> Hi Tim.
> I'm a programerr in PHP4 for about  years now and just by looking at your
> script i can tell it wont work !
>
> First of all, if would be dificult for a begginer developer to implement in
> their script.
> For more advanced developers it will be a great challenge for them to try to
> get ti to work !
>
> I've created my own little Row Alternator for pulling rows from a table.
>
> if(ereg("1$|3$|5$|7$|9$", $i)) {
>  $bg[$i] = "#33";
> } else {
>  $bg[$i] = "#339966";
> }
>
> Place this script snipet in the function where you have detected if there is
> actually a result and then just call the bg like this
>
> echo "\n";
>
> This sould help alot more.
> Please dont think that I'm hammering your scripting skills.
> I'm not.
> Just a thought.
>
> Regards
> Vins.
> [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Re: TO TIM FOSTER - REGARDING THE ALTERNATING ROWS PULLED FROM TABLES

2001-12-04 Thread Manuel Lemos

Hello,

Vins wrote:
> 
> Hi Tim.
> I'm a programerr in PHP4 for about  years now and just by looking at your
> script i can tell it wont work !
> 
> First of all, if would be dificult for a begginer developer to implement in
> their script.
> For more advanced developers it will be a great challenge for them to try to
> get ti to work !
> 
> I've created my own little Row Alternator for pulling rows from a table.
> 
> if(ereg("1$|3$|5$|7$|9$", $i)) {

Wouldn't it be simpler if you just did:

if($i % 2) {


Anyway, you may want to check this class that not only displays rows
alternating their colors, but also highlights the rows when the mouse is
over the and can also show links to go back and forth pages with with a
limited number or rows:

http://phpclasses.upperdesign.com/browse.html/package/130

Regards,
Manuel Lemos


>  $bg[$i] = "#33";
> } else {
>  $bg[$i] = "#339966";
> }
> 
> Place this script snipet in the function where you have detected if there is
> actually a result and then just call the bg like this
> 
> echo "\n";
> 
> This sould help alot more.
> Please dont think that I'm hammering your scripting skills.
> I'm not.
> Just a thought.
> 
> Regards
> Vins.
> [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]