RE: [PHP-DB] Select Statement with output in different colors.
Try this $query = 'SELECT * FROM table $mysql_result = mysql_query($query, $link); while($row = mysql_fetch_array($mysql_result)) { switch ($row[event] ) { case event_one: $bg = 'blue' break; case event_one: $bg = 'red' break; case event_one: $bg = 'green' break; default: $bg = 'white' } print 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// end while HTH Peter -Original Message- From: Christopher Lyon [mailto:[EMAIL PROTECTED] Sent: 17 June 2003 22:35 To: [EMAIL PROTECTED] Subject: [PHP-DB] Select Statement with output in different colors. I have a php script that does some select statements, on mysql, and outputs that to a table. I would like to change the color of the table row depending upon one of the fields. The select statements are from a syslog database that I have and I would like to highlight key events by changing the colors for that row. Example would be MAJOR, yellow and INFO, green. Does anybody have any examples of how to do this? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Select Statement with output in different colors.
Here's a slight alteration to Peter's code in case someone isn't familiar with switch statements. Ooh, such a bad pun, as if there's any other kind. ? $query = 'SELECT * FROM table $mysql_result = mysql_query($query, $link); while($row = mysql_fetch_array($mysql_result)) { switch ($row[event] ) { case event_one: $bg = 'blue' break; case event_two: $bg = 'red' break; case event_three: $bg = 'green' break; default: $bg = 'white' } print 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// end while ? Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Peter Lovatt [EMAIL PROTECTED] To: Christopher Lyon [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, 17 June, 2003 17:42 Subject: RE: [PHP-DB] Select Statement with output in different colors. Try this $query = 'SELECT * FROM table $mysql_result = mysql_query($query, $link); while($row = mysql_fetch_array($mysql_result)) { switch ($row[event] ) { case event_one: $bg = 'blue' break; case event_one: $bg = 'red' break; case event_one: $bg = 'green' break; default: $bg = 'white' } print 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// end while HTH Peter -Original Message- From: Christopher Lyon [mailto:[EMAIL PROTECTED] Sent: 17 June 2003 22:35 To: [EMAIL PROTECTED] Subject: [PHP-DB] Select Statement with output in different colors. I have a php script that does some select statements, on mysql, and outputs that to a table. I would like to change the color of the table row depending upon one of the fields. The select statements are from a syslog database that I have and I would like to highlight key events by changing the colors for that row. Example would be MAJOR, yellow and INFO, green. Does anybody have any examples of how to do this? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] Select Statement with output in different colors.
Thank you for the heads up. I did notice that is must have a ; after every variable case entry, e.g. $bg = 'blue'; in order to work right. That was at least how I had to get it working. -Original Message- From: Becoming Digital [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 17, 2003 9:51 PM To: [EMAIL PROTECTED] Subject: Re: [PHP-DB] Select Statement with output in different colors. Here's a slight alteration to Peter's code in case someone isn't familiar with switch statements. Ooh, such a bad pun, as if there's any other kind. ? $query = 'SELECT * FROM table $mysql_result = mysql_query($query, $link); while($row = mysql_fetch_array($mysql_result)) { switch ($row[event] ) { case event_one: $bg = 'blue' break; case event_two: $bg = 'red' break; case event_three: $bg = 'green' break; default: $bg = 'white' } print 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// end while ? Edward Dudlik Becoming Digital www.becomingdigital.com - Original Message - From: Peter Lovatt [EMAIL PROTECTED] To: Christopher Lyon [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, 17 June, 2003 17:42 Subject: RE: [PHP-DB] Select Statement with output in different colors. Try this $query = 'SELECT * FROM table $mysql_result = mysql_query($query, $link); while($row = mysql_fetch_array($mysql_result)) { switch ($row[event] ) { case event_one: $bg = 'blue' break; case event_one: $bg = 'red' break; case event_one: $bg = 'green' break; default: $bg = 'white' } print 'tr bgcolor='.$bg.' tdda da da nbsp;/td /tr'; }// end while HTH Peter -Original Message- From: Christopher Lyon [mailto:[EMAIL PROTECTED] Sent: 17 June 2003 22:35 To: [EMAIL PROTECTED] Subject: [PHP-DB] Select Statement with output in different colors. I have a php script that does some select statements, on mysql, and outputs that to a table. I would like to change the color of the table row depending upon one of the fields. The select statements are from a syslog database that I have and I would like to highlight key events by changing the colors for that row. Example would be MAJOR, yellow and INFO, green. Does anybody have any examples of how to do this? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php