[PHP] Alternate row colours - what is wrong with this code?

2003-01-17 Thread Denis L. Menezes
Hello Guys,

I want alternating colours in the output table. Can someone tell me what is wrong with 
this code? I get the data but no alternating colours.

Quote :

 ?php
 $cols = array('#ff','#00ff00');
 $i = 0;
 while($row=mysql_fetch_array($result)){ 
  echo 'tr bgcolor='.$cols[$i++%2].'';
Print td width=\12%\ align=\center\ height=\6\ bgcolor=\#bf\font 
face=\Tahoma\ color=\#00\ ;
 Print   b font size=\2\ color=\ff\ $row[OrgName] /b/font;
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\ bgcolor=\#bf\font 
size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Country]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\ bgcolor=\#bf\font 
size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Date]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\ bgcolor=\#bf\font 
size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Number]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\ bgcolor=\#b7b700\font 
size=\2\ face=\Tahoma\ color=\#00\ ;
 Print form action=\fullmarks.php\ method=\post\;
PrintINPUT TYPE=\submit\ value=\View details\ Name=\Details\;
Printinput type=\hidden\ name=\SelectedItemNumber\ value= $row[Id];
 print /td;
 Print /form;
Print /tr;}
   }
 ?


Unquote.


Thanks
Denis


RE: [PHP] Alternate row colours - what is wrong with this code?

2003-01-17 Thread Clarkson, Nick

I think it's because you're setting the bgcolor=#bf for the TD tag, so
it's overriding using the TR tag bgcolor. The maths is OK, so if you remove
the td bgcolor bit it *should* (standard disclaimer) work.

Nick

-Original Message-
From: Denis L. Menezes [mailto:[EMAIL PROTECTED]]
Sent: 17 January 2003 12:12
To: PHP general list
Subject: [PHP] Alternate row colours - what is wrong with this code?


Hello Guys,

I want alternating colours in the output table. Can someone tell me what is
wrong with this code? I get the data but no alternating colours.

Quote :

 ?php
 $cols = array('#ff','#00ff00');
 $i = 0;
 while($row=mysql_fetch_array($result)){ 
  echo 'tr bgcolor='.$cols[$i++%2].'';
Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font face=\Tahoma\ color=\#00\ ;
 Print   b font size=\2\ color=\ff\ $row[OrgName] /b/font;
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Country]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Date]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Number]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#b7b700\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print form action=\fullmarks.php\ method=\post\;
PrintINPUT TYPE=\submit\ value=\View details\ Name=\Details\;
Printinput type=\hidden\ name=\SelectedItemNumber\ value=
$row[Id];
 print /td;
 Print /form;
Print /tr;}
   }
 ?


Unquote.


Thanks
Denis


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


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




Re: [PHP] Alternate row colours - what is wrong with this code?

2003-01-17 Thread Jason Wong
On Friday 17 January 2003 20:11, Denis L. Menezes wrote:
 Hello Guys,

 I want alternating colours in the output table. Can someone tell me what is
 wrong with this code? I get the data but no alternating colours.

 Quote :

  ?php
  $cols = array('#ff','#00ff00');
  $i = 0;
  while($row=mysql_fetch_array($result)){
   echo 'tr bgcolor='.$cols[$i++%2].'';

Look at the HTML source of the resulting page, if each tr bgcolor... is 
alternating then your code is working. Which means your HTML is dodgy ...

 Print td width=\12%\ align=\center\ height=\6\
 bgcolor=\#bf\font face=\Tahoma\ color=\#00\ ; Print  

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
There are no winners in life, only survivors.
*/


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




Re: [PHP] Alternate row colours - what is wrong with this code?

2003-01-17 Thread Chris Hayes
At 13:11 17-1-2003, you wrote:
 I want alternating colours in the output table. Can someone tell me what 
is wrong with this code? I get the data but no alternating colours.

It has to do with the $cols[$i++%2] part.

When I try to print $i++%2 the outcome varies between 1 and none.  Somehow 
the complete row is not show anymore.

The easiest way is to stop trying this approach and move to the tested 
versions i mailed to this list about an hour ago.


Further i would suggest to keep the form within the td/td bit and not 
overlap it.


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



RE: [PHP] Alternate row colours - what is wrong with this code?

2003-01-17 Thread Clarkson, Nick

I've just tested this stripped down (some colours changed) version of your
code and I get alternating rows no problem. On another point, without the
TABLE tags it won't work properly. I think your PHP works fine, it's your
HTML ;o)

Nick

?php
$cols = array('#ff','#00ff00');
print TABLE;
for ($i = 0; $i10;) {
print 'tr bgcolor='.$cols[$i++%2].'';
print td width=\12%\ align=\center\ height=\6\font face=\Tahoma\
size=\2\ color=\55\TEST/font ;
print nbsp;/td/tr;
}
print /TABLE;
?





-Original Message-
From: Denis L. Menezes [mailto:[EMAIL PROTECTED]]
Sent: 17 January 2003 12:12
To: PHP general list
Subject: [PHP] Alternate row colours - what is wrong with this code?


Hello Guys,

I want alternating colours in the output table. Can someone tell me what is
wrong with this code? I get the data but no alternating colours.

Quote :

 ?php
 $cols = array('#ff','#00ff00');
 $i = 0;
 while($row=mysql_fetch_array($result)){ 
  echo 'tr bgcolor='.$cols[$i++%2].'';
Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font face=\Tahoma\ color=\#00\ ;
 Print   b font size=\2\ color=\ff\ $row[OrgName] /b/font;
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Country]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Date]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#bf\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print  $row[Number]; 
 print /font  nbsp;/td;
 Print td width=\12%\ align=\center\ height=\6\
bgcolor=\#b7b700\font size=\2\ face=\Tahoma\ color=\#00\ ;
 Print form action=\fullmarks.php\ method=\post\;
PrintINPUT TYPE=\submit\ value=\View details\ Name=\Details\;
Printinput type=\hidden\ name=\SelectedItemNumber\ value=
$row[Id];
 print /td;
 Print /form;
Print /tr;}
   }
 ?


Unquote.


Thanks
Denis


This private and confidential e-mail has been sent to you by Egg.
The Egg group of companies includes Egg Banking plc
(registered no. 2999842), Egg Financial Products Ltd (registered
no. 3319027) and Egg Investments Ltd (registered no. 3403963) which
carries out investment business on behalf of Egg and is regulated
by the Financial Services Authority.  
Registered in England and Wales. Registered offices: 1 Waterhouse Square,
138-142 Holborn, London EC1N 2NA.
If you are not the intended recipient of this e-mail and have
received it in error, please notify the sender by replying with
'received in error' as the subject and then delete it from your
mailbox.


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