Only output array if not null

I have a field ‘Category2ID’ that lists 0 or the category ID. When I list the values of the array it lists
0
0
0
402

402 is the category2ID I need. Is it possible to not output the 0 values?

this is my code now:
[php]
$sqlIndustry = “SELECT Category2ID FROM products order by Category2ID asc”;
$resultIndustry = mysql_query($sqlIndustry, $conn);
if (mysql_num_rows($resultIndustry) == 0) {
//do something here
} else {
while($row = mysql_fetch_array($resultIndustry)) {
echo "


“.stripslashes($row[‘Category2ID’]).”

";
}
}
[/php]

Something like this should work

[php]
$sqlIndustry = “SELECT Category2ID FROM products order by Category2ID asc”;
$resultIndustry = mysql_query($sqlIndustry, $conn);
if (mysql_num_rows($resultIndustry) == 0) {
//do something here
} else {
while($row = mysql_fetch_array($resultIndustry)) {
$catID = stripslashes($row[‘Category2ID’]);

	if($catID == "0"){
		echo "";
	} else {
     echo "
       <tr>
           <td>$catID</td>
       </tr>
       ";
	}

}
}
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service