As the title says, I want to hide an item is the product name doesn't exist.
The problem here is.. When it show the products for the user, it actually show nothing where the //show nothing is placed instead of showing a new product that has a product name.
So sometime it shows 10 products, sometime it shows 5 products, which is not what i want.
I want it to show a new product if a product name is not there.
Any clues on what i change in my code?
my current code is:
Picks 12 random product from the database:
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY RAND() LIMIT 12");
Shows the products for the user:
if($product_name == ''){
//Show nothing
}else{
$dynamicList .=
'<table border="0" id="indexproducts" style="margin-left:22px; margin-bottom:20px;">
<tr>
<td id="indexproductfoto" align="center">
<a href="http://www.mysite.com/id/'.$id.'/'.$seo8.'/">
<img src="http://www.mysite.com/inventoryimages/'.$id.'.jpg" onerror="this.src=\'http://www.mysite.com/inventoryimages/x.jpg\';" />
</a>
</td>
</tr>
<tr>
<td id="indexproducttext2"><strong>'.$product_name.'</strong><br />
</td>
</tr>
<tr>
<td style="color:#F00" id="indexproducttext"><strong>Pris: '.round($price).':-</strong></td>
</tr>
<tr>
<td style="color:#F00" id="indexproducttext"><strong>(Exkl.moms: '.round($price1).':-)</strong></td>
</tr>
<tr>
<td id="indexproducttext"><a href="http://www.mysite.com/id/'.$id.'/'.$seo8.'/">Produktinformation</a></td>
</tr>
</table>';
}
}