The code below works fine. It prints elements in a MySQL database as an HTML table. However, there are records in the database where the first column (the "site" variable) is empty. How can I make this table exclude rows / records where the "site" is empty?
$result=mysql_query("SHOW TABLES FROM database LIKE '$find'")
or die(mysql_error());
if(mysql_num_rows($result)>0){
while($table=mysql_fetch_row($result)){
print "<p class=\"topic\">$table[0]</p>\n";
$r=mysql_query("SELECT * , itemsa - itemsb AS itemstotal FROM `$table[0]` ORDER BY itemstotal DESC");
print "<table class=\"navbar\">\n";
while($row=mysql_fetch_array($r)){
$itemstotal = $row['itemsa'] - $row['itemsb'];
print "<tr>";
print "<td class='sitename'>".'<a type="amzn" category="books" class="links2">'.$row['site'].'</a>'."</td>";
print "<td class='class1'>".'<span class="class1_count" id="class1_count'.$row['id'].'">'.number_format($itemstotal).'</span>'."</td>";
print "<td class='selector'>".'<span class="button" id="button'.$row['id'].'">'.'<a href="javascript:;" class="cell1" id="'.$row['id'].'">'.Select.'</a>'.'</span>'."</td>";
}
print "</tr>\n";
}
print "</table>\n";
}
else{
print "";
}
John
source
share