FairyBusiness
asked on
How to keep value from showing if its empty?
Hi, my function is showing images like I want.
but there always seems to be one image that doesnt show and it says its information is nothing. I check my database many times to make sure there are no empty fields and there are none.
http://auroriella.com/index.php
I tried this:
if($featured != "") {
and
if(!empty($featured)) {
but its still letting values in that are nothing! Any ideas?
but there always seems to be one image that doesnt show and it says its information is nothing. I check my database many times to make sure there are no empty fields and there are none.
http://auroriella.com/index.php
I tried this:
if($featured != "") {
and
if(!empty($featured)) {
but its still letting values in that are nothing! Any ideas?
// Displays the featured products randomly
function featured_products() {
global $conn;
/*
$query = "SELECT * FROM bracelets WHERE featured=1 ";
$query .= "UNION ALL SELECT * FROM earrings WHERE featured=1 ";
$query .= "UNION ALL SELECT * FROM necklaces WHERE featured=1 ";
*/
$query = "SELECT 'bracelets' as theTable, id, filename FROM bracelets WHERE featured=1 ";
$query .= " UNION ALL SELECT 'earrings' as theTable, id, filename FROM earrings WHERE featured=1 ";
$query .= " UNION ALL SELECT 'necklaces' as theTable, id, filename FROM necklaces WHERE featured=1 ";
$result = mysql_query($query, $conn) ;
confirm_query($result);
$output = "";
// These loops output the subject names with their corresponding pages underneath them
$featured=array();
while ($featured[] = mysql_fetch_assoc($result))
{
//do nothing here
};
//"randomize"
shuffle($featured);
if($featured != "") {
foreach($featured as $images){
$output .= "<a href=\"" . substr($images['theTable'], 0, -1) . ".php?item=" . urlencode($images['id']) . "\">";
$output .= "<img src=\"" . $images['theTable'] .'/'.$images['filename'] . ".png\" />";
}
}
return $output;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try changing that to if ($images['filename'] != "")
ASKER