[PHP] Different colors on lines
Can anyone help out with this ?? Since i do the search after the query, there is an problem if line 1 in the Sql table matches, line 2 does not, but line 3 does. Then the result will display the same color on the two lines That would be printet in this example. How can i make sure that it will allways display the colors On each line ?? Regards Bård Tommy Nilsen $query_1 = mysql_query(select * from $tabell_4); $number_1 = mysql_numrows($query_1) ; $i_1 = 0; $bgcolor[0] = #FFE38E; $bgcolor[1] = #FF; $Search = Test; while ($i_1 $number_1) { $Name = mysql_result($query_1,$i_1,Name); if (eregi ($Search, $Name)) { Echo 'tr BGCOLOR='.$bgcolor[$i_1%2].''; } $i++; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Different colors on lines
have a seperate counter $query = mysql_query(select * from $tabell_4); $number = mysql_numrows($query) ; $i = 0; $bgcolor[0] = #FFE38E; $bgcolor[1] = #FF; $Search = Test; $j = 0 while ($i $number) { $Name = mysql_result($query_1,$i,Name); if (eregi ($Search, $Name)) { Echo 'tr BGCOLOR='.$bgcolor[$j%2].''; $j++; } $i++; } -Original Message- From: Bård Tommy Nilsen [mailto:[EMAIL PROTECTED]] Sent: Friday, June 14, 2002 4:21 PM To: '[EMAIL PROTECTED]' Subject: [PHP] Different colors on lines Can anyone help out with this ?? Since i do the search after the query, there is an problem if line 1 in the Sql table matches, line 2 does not, but line 3 does. Then the result will display the same color on the two lines That would be printet in this example. How can i make sure that it will allways display the colors On each line ?? Regards Bård Tommy Nilsen $query_1 = mysql_query(select * from $tabell_4); $number_1 = mysql_numrows($query_1) ; $i_1 = 0; $bgcolor[0] = #FFE38E; $bgcolor[1] = #FF; $Search = Test; while ($i_1 $number_1) { $Name = mysql_result($query_1,$i_1,Name); if (eregi ($Search, $Name)) { Echo 'tr BGCOLOR='.$bgcolor[$i_1%2].''; } $i++; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Different colors on lines
Hello, Check out the following link. http://www.zend.com/codex.php?CID=322 There are various code examples for alternating table backgrounds. Hope this helps, Chris Bunting _ Send and receive Hotmail on your mobile device: http://mobile.msn.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Different colors on lines
On Fri, 14 Jun 2002, Bård Tommy Nilsen wrote: Can anyone help out with this ?? Since i do the search after the query, there is an problem if line 1 in the Sql table matches, line 2 does not, but line 3 does. Then the result will display the same color on the two lines That would be printet in this example. How can i make sure that it will allways display the colors On each line ?? $query_1 = mysql_query(select * from $tabell_4); $number_1 = mysql_numrows($query_1) ; $i_1 = 0; $bgcolor[0] = #FFE38E; $bgcolor[1] = #FF; $Search = Test; while ($i_1 $number_1) { $Name = mysql_result($query_1,$i_1,Name); if (eregi ($Search, $Name)) { Echo 'tr BGCOLOR='.$bgcolor[$i_1%2].''; } $i++; } $bgcolor[0] = #FFE38E; $bgcolor[1] = #FF; $i = 0; while ($row = mysql_fetch_assoc($query_1)) { $name = $row['name']; if (eregi($search, $name)) echo 'tr bgcolor=' . $bgcolor[$i = 1 - $i] . ''; } miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php