Web Hosting Vodahost    

Home Take The Royal Tour! Order Now Features Prices
Go Back   Web Hosting > VodaHost Web Hosting Support > mySQL & PHP

Notices

mySQL & PHP Discussions, information and help with mySQL and PHP.

Reply
 
Thread Tools
  #1  
Old 07-14-2009, 07:11 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Question How to alternate background colour of rows

Hi Folks,

We have managed to gather the data from MySQL to veiw as seen at www.gnjgf.co.za/watflip.php

I would however like to create the option of perhaps showing the data as I can show from the link at http://uploads.saga.co.za/rankings/rateindx.htm

The rows alternate in colour.

If there is someone out there who can help I look forward to your replies.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old 07-16-2009, 12:46 PM
Private
 
Join Date: Jul 2009
Location: FRANCE
Posts: 3
Default Re: How to alternate background colour of rows

good info..thanx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old 07-16-2009, 09:24 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Question Re: How to alternate background colour of rows

Hi Folks,

In my efforts to get this to work - I am now receiveing an error:

Fatal error: Call to undefined function row_color() in /home/******/public_html/gnjgf/watflip.php on line 111

I would appreciate it if someone could help in this regard
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old 07-17-2009, 01:00 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,052
Default Re: How to alternate background colour of rows

I can't know what you have done, as you seem to be calling a non defined function.

Anyway, there are also very simple ways to do this directly in your table <td> definition.

You add a counter ($i) which autoincrements by 1 for each row.
Then you add this code (just an example):

$bgcolor1 = "#222224";
$bgcolor2 = "#808080";
$bgcolor = $bgcolor1;
if($i%2 == "0"){
$bgcolor = $bgcolor2;
}


And in your <td> definition you add this:

echo '....your code

<td bgcolor="'.$bgcolor.'"> rest of cel code....

... rest of code....
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old 07-17-2009, 02:46 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Thumbs up Re: How to alternate background colour of rows

Hi George,

Thanks for the info - I will have a look at it and see if I can get it to work better.

My big difficulty is identifying exactly where to place this info.

Let me try and if I get stuck I will post agian
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old 07-17-2009, 03:56 PM
PlayItByBeer's Avatar
www.froggdesigns.com
 
Join Date: Mar 2007
Location: Port Elizabeth, South Africa
Posts: 636
Send a message via Yahoo to PlayItByBeer Send a message via Skype™ to PlayItByBeer
Default Re: How to alternate background colour of rows

Hi Rob,

Just to throw a spanner in the works but i know you are busy with the script. Are you not openning yourself up to member complaints, by showing their contact details... it's an online golfers database now. LOL

We seem to get enough calls from telesales people who always call at the wrong time in SA.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old 07-17-2009, 05:33 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Thumbs up Re: How to alternate background colour of rows

Hi Andrew,

Your sentiments are exactly the same as mine and I agree with you whole heartedly.

This page is my test page and once complete you will need to use a login to access. The page name will also be changing to be included to the site better and other applications that will be coming.

My php skills being very limited the process is extremly slow - I not complaining - i am learning

Hope all is well down there.
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old 07-17-2009, 07:55 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Question Re: How to alternate background colour of rows

Hi George,

I have found this text which seems to be similar:
<?php

$color1="#FFFFCC"; //First Colour
$color2="none"; // Second Colour
$row_count=0; //Set row_count to 0
while($m=mysql_fetch_array($quey1)) //SQL query
{
$row_count++;//Counts row_count
$row_color = ($row_count % 2) ? $color1 : $color2; //Gets the colour to be used
print "<tr style='background:{$row_color}'> //Sets the row colour.
}

If so where would I insert it.

I have tried your method but dont get any where near the required result.

Any other views would be most welcome
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com

Last edited by Rob (SA); 07-17-2009 at 07:59 PM. Reason: missing info
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old 07-17-2009, 09:16 PM
navaldesign's Avatar
General & Forum Moderator
 
Join Date: Oct 2005
Location: Italy
Posts: 10,052
Default Re: How to alternate background colour of rows

Rob, it depends on the rest of your code, how can i ever know it ?

Usually the first part (the two colors definition) goes before the loop, the counter part (i said $i, you say $row_count, the concept is the same) goes before or immediately after the <table> definition:

code................
$bgcolor1 = "#222224";
$bgcolor2 = "#808080";
echo'
<table id=.......... etc>';
while(....loop){
$bgcolor = $bgcolor1;
if($i%2 == "0"){
$bgcolor = $bgcolor2;
}
echo '<tr>
<td bgcolor = '.$bgcolor.'>cell content.........
</tr>
more <td>'s...................of the same recordset
';
}
echo '<table>';


etc
__________________
Navaldesign
Logger Lite: Low Cost, Customizable, multifeatured Login script
Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old 07-17-2009, 11:48 PM
Rob (SA)'s Avatar
Major
 
Join Date: Nov 2006
Location: Centurion, South Africa
Posts: 483
Thumbs up Re: How to alternate background colour of rows

Hi George,

I have it working - thank you
__________________
Kind Regards
Rob
www.gnjgf.co.za
www.oryan-projects.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT +1. The time now is 08:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC7
2005-2009 VodaHost Web Hosting Your Perfect Web Host - All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203