I wonder may I set 2 different conditions to WHERE when I’m taking data from database? For example I’d like to select data [B]where status=1[B]membership=admin
I guess it’s not possible so I’m trying select my 2nd condition using “if” but I have problem with WHILE when I need use both if/else.
Result I need:
[IMG]
My script (doesn’t show results from “else”):
[code=php]
<table>
<?php
$sql=”SELECT * FROM $tbl_name WHERE status = 1 ORDER BY name”;
$result=mysql_query($sql);
?>
<tr><th colspan=”4″>ADMINS</th></tr>
<?php
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
if($rows[‘membership’] == ‘admin’)
{
?>
<tr><td>…</td><td>…</td><td>…</td><td>…</td></tr>
<?php
// close if statement
}
?>
<tr><th colspan=”4″>MEMBERS</th></tr>
<?php
else {
?>
<tr><td>…</td><td>…</td><td>…</td><td>…</td></tr>
<?php
// close else statement
}
// close while loop
}
// close connection
mysql_close();
?>
</table>