I am trying to only show the charges if they are in the database..
I am querying a table for the subject information and also show the charges associated with each subject.
What I am trying to do with the code is to only show charges if they exist. I know I can do it with just showing the $charge1 fields but this is how I am attempting to do it.
Here is the page:
[html]
http://www.tnrcso.org/wanted.php
[/html]here is the php code[php]<?
include ("top.php");
include ("nav.php");
?>
<td width=75% valign=top>
<table border=0 width=100% class=leftMenutop1>
<td><span class='text'>
<p class='bodyHead1'>Roane County Sheriff's Office Most Wanted Fugitives</span></p>
<table border=0 width=99% class="addalert">
<td valign=top><img src='img/alert.gif' align=left></td>
<td><span class='text1'>These fugitives should be considered ARMED and DANGEROUS! NEVER attempt to apprehend a fugitive yourself.
If you have information on the location of any of these fugitives, contact the Roane County Sheriff's Office at (865) 717-4700 or dial 911</td></table>
<br>
<?
include('db.php');
echo "<table border=0 width=99% cellpadding=2 cellspacing=0 class='pbox14'>";
$query1 = mysql_query("SELECT * FROM `wanted` ORDER BY `id`");
while ($row1 = mysql_fetch_array($query1))
{
$id = $row1['id'];
$first = $row1['first'];
$last = $row1['last'];
$address = $row1['address'];
$city = $row1['city'];
$state = $row1['state'];
$city = $row1['city'];
$zip = $row1['zip'];
$charge1 = $row1['charge1'];
$charge2 = $row1['charge2'];
$charge3 = $row1['charge3'];
$charge4 = $row1['charge4'];
$charge5 = $row1['charge5'];
$charge6 = $row1['charge6'];
$charge7 = $row1['charge7'];
$charge8 = $row1['charge8'];
$charge9 = $row1['charge9'];
$charge10 = $row1['charge10'];
$qq = mysql_num_rows(mysql_query("SELECT * FROM `wimage` WHERE `news_id`='$id'"));
$mug11 = ($qq>0) ? "<img src=\"../news/wimage/t$file\" border=1>" : '';
echo "<td colspan=3 class='wanted1'> $first $last</td><tr>
<td width=100 valign=top>";
$q = mysql_query ("SELECT * from wimage WHERE news_id=$id");
while ($Row6 = mysql_fetch_array($q))
{
echo "<img src=\"../news/wimage/t{$Row6['file']}\" border=1></td>";
}
echo "</td>
<td valign=top><span class='text1'><B>$first $last</b><br>$address<br>$city, $state $zip</td>
<td valign=top><span class='text1'><b>Charges</b><bR>";
if ($row1['charge1']==0) { echo "1. $charge1 <Br>"; } else { echo ""; };
if ($row1['charge2']==0) { echo "2. $charge2 <Br>"; } else { echo ""; };
if ($row1['charge3']==0) { echo "3. $charge3 <br>"; } else { echo ""; };
if ($row1['charge4']==0) { echo "4. $charge4 <br>"; } else { echo ""; };
if ($row1['charge5']==0) { echo "5. $charge5 <br>"; } else { echo ""; };
if ($row1['charge6']==0) { echo "6. $charge6 <br>"; } else { echo ""; };
if ($row1['charge7']==0) { echo "7. $charge7 <br>"; } else { echo ""; };
if ($row1['charge8']==0) { echo "8. $charge8 <br>"; } else { echo ""; };
if ($row1['charge9']==0) { echo "9. $charge9 <br>"; } else { echo ""; };
if ($row1['charge10']==0) { echo "10. $charge10 <br>"; } else { echo ""; };
echo "
</td><tr>";
}
echo "</td></table><br>";
?>
<table border=0 width=99% class="addalert">
<td valign=top><img src='img/alert.gif' align=left></td>
<td><span class='text1'>These fugitives should be considered ARMED and DANGEROUS! NEVER attempt to apprehend a fugitive yourself.
If you have information on the location of any of these fugitives, contact the Roane County Sheriff's Office at (865) 717-4700 or dial 911</td></table>
<br><br><Br>
</td></table>
</td></table>
<?
include ("bot.php");[/php]Thank you