You can do a simple if statement. Instead of using a foreach I would use a
while with list
Example in pseudocode:
(while(list($col1, $col2, $col3) = @mysql_fetch_row($resultID))
and then
if ($col3 == value1)
echo "td stuff with bgcolor = whatever";
else
echo "td stuff with bgcolor = something else";
end if
echo "$col3";
make sense?
Respectfully,
Ligaya Turmelle
""CurlyBraces Technologies ( Pvt ) Ltd"" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
----- Original Message -----
From: CurlyBraces Technologies ( Pvt ) Ltd
To: Eve Atley
Sent: Tuesday, February 24, 2004 2:15 AM
Subject: Re: MySql and php
thanx alot for ur reply , i think better to send my script to u .In third
collom , there is two different status . I want to highlight those with two
different colors.There is to be satisfied some simple condition , plz help
thanx
curlys
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "root", "*****")
or die("Could not connect");
/*print "Connected successfully";*/
mysql_select_db("smsc") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM ServiceStatus";
$result = mysql_query($query) or die("Query failed");
/* Printing results in HTML */
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>
----- Original Message -----
From: Eve Atley
To: CurlyBraces Technologies ( Pvt ) Ltd
Sent: Tuesday, February 24, 2004 4:52 AM
Subject: RE: MySql and php
You want the rows to alternate colors in the table, you mean? That's easy.
<?
function alternate_2colors($color_1, $color_2, $cpt)
{
$colors = ($cpt % 2) ? $color_1 : $color_2;
return $colors;
}
while ($row = mysql_fetch_array($result_jobslisting, MYSQL_ASSOC)) {
$nb += 1;
$colors = alternate_2colors('#C0C0C0', '#FFFFFF', $nb);
?>
<tr bgcolor="<?php echo $colors; ?>">
<td width="39%">
html content here
</td>
</tr>
<?
}
?>
------------------------
Eve Atley
WOW Corporation LLC.
555 North Bell Ave.
Carnegie, PA 15106
TEL: 412-278-1838
CELL: 412-716-6060
-----Original Message-----
From: CurlyBraces Technologies ( Pvt ) Ltd [mailto:[EMAIL PROTECTED]
Sent: Monday, February 23, 2004 10:05 AM
To: [EMAIL PROTECTED]
Subject: MySql and php
hi ,
i have a problem with Mysql Vs php .. Can somebody help me to sort out this
problem ?
I wrote a php script to connet mysql data base and get some data from some
table of the database. It works well ..
1 data1 data2
5 ccc xcx
3 aaa 123
2 klkl opop
4 opop pop
I want do the sort for the fields while its showing from the web. and in the
third data field i want to add some colors while its running in the html .
can some body help me to do the scripting plz ?
thanx in advace
curlys
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]