Man, I need help. :D
I have a database and the table has 4 fields.
ident, chroma, hue, value
I have the script to display ALL the data into the table. But what I am looking to do is to set a condition for displaying only data i want.
For example:
Only list the items in the table that fit this condition:
Here is my current code that just displays the data in a table:
[PHP]<?
include("XXXXXX XX.php");
mysql_connect($ dbhost,$usernam e,$password);
@mysql_select_d b($database) or die( "Unable to select database");
$query="SELECT * FROM rembrandt";
$result=mysql_q uery($query);
$num=mysql_numr ows($result);
mysql_close();
echo "<b><center>Dat abase Output</center></b><br><br>";
?>
<table border="1" cellspacing="6" cellpadding="6" >
<tr>
<th><font face="Arial, Helvetica, sans-serif">Pastel Identifier</font></th>
<th><font face="Arial, Helvetica, sans-serif">Hue</font></th>
<th><font face="Arial, Helvetica, sans-serif">Chroma</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$ident=mysql_re sult($result,$i ,"ident");
$hue=mysql_resu lt($result,$i," hue");
$chroma=mysql_r esult($result,$ i,"chroma");
$value=mysql_re sult($result,$i ,"value");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$ident"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$hue"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$chroma"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$value"; ?></font></td>
</tr>
<?
$i++;
}
echo "</table>";
?>[/PHP]
I have tried putting this IF statement in but with no success as I really don't know where to put it.
Can someone help me here.
Thank you!!!!!
I have a database and the table has 4 fields.
ident, chroma, hue, value
I have the script to display ALL the data into the table. But what I am looking to do is to set a condition for displaying only data i want.
For example:
Only list the items in the table that fit this condition:
chroma=7
value=9
value=9
Here is my current code that just displays the data in a table:
[PHP]<?
include("XXXXXX XX.php");
mysql_connect($ dbhost,$usernam e,$password);
@mysql_select_d b($database) or die( "Unable to select database");
$query="SELECT * FROM rembrandt";
$result=mysql_q uery($query);
$num=mysql_numr ows($result);
mysql_close();
echo "<b><center>Dat abase Output</center></b><br><br>";
?>
<table border="1" cellspacing="6" cellpadding="6" >
<tr>
<th><font face="Arial, Helvetica, sans-serif">Pastel Identifier</font></th>
<th><font face="Arial, Helvetica, sans-serif">Hue</font></th>
<th><font face="Arial, Helvetica, sans-serif">Chroma</font></th>
<th><font face="Arial, Helvetica, sans-serif">Value</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$ident=mysql_re sult($result,$i ,"ident");
$hue=mysql_resu lt($result,$i," hue");
$chroma=mysql_r esult($result,$ i,"chroma");
$value=mysql_re sult($result,$i ,"value");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$ident"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$hue"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$chroma"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$value"; ?></font></td>
</tr>
<?
$i++;
}
echo "</table>";
?>[/PHP]
I have tried putting this IF statement in but with no success as I really don't know where to put it.
if ( $chroma=7 && $value=9 ) {
Can someone help me here.
Thank you!!!!!
Comment