I have problem in my PHP code. I'm trying to make internet shop and Im now in product listing step. My code is so long, so I will show only substantial part.
$result = mysql_query("SELECT name, category, describtion, value FROM products") or die(mysql_error());
if(mysql_num_rows($result) % 2 == 0)
{
while($left = mysql_fetch_array($result, MYSQL_NUM) && $right = mysql_fetch_array($result, MYSQL_NUM))
{
echo '
<div class="sub_items">
<div class="sub_left">
<div class="sub_items_header">
<h1>'.$left[0].'</h1>
<h2>'.$left[1].'</h2>
</div>
<div class="sub_items_image">
<img src="images/'.$left[0].'.png" width="167" height="164" alt="'.$left[0].'" />
</div>
<div class="sub_items_text">
'.$left[2].'
</div>
<div class="sub_items_cartinfo">
<div class="price">
<h2>'.$left[3].'$</h2>
</div>
<div class="addtocart">
<a href="chart.php?name='.$left[0].'"><span>Add to Cart</span></a>
</div>
<div class="clearthis"> </div>
</div>
<div class="clearthis"> </div>
</div>
<div class="sub_right">
<div class="sub_items_header">
<h1>'.$right[0].'</h1>
<h2>'.$right[1].'</h2>
</div>
<div class="sub_items_image">
<img src="images/'.$right[0].'.png" width="175" height="170" alt="'.$right[0].'" />
</div>
<div class="sub_items_text">
'.$right[2].'
</div>
<div class="sub_items_cartinfo">
<div class="price">
<h2>'.$right[3].'$</h2>
</div>
<div class="addtocart">
<a href="chart.php?name='.$right[0].'"><span>Add to Cart</span></a>
</div>
<div class="clearthis"> </div>
</div>
<div class="clearthis"> </div>
</div>
<!-- End of Right Sub Item -->
<div class="clearthis"> </div>
</div>
<div class="h_divider"> </div>
';
}
In the while cycle I'm echoing data. Data is separated to left and right div. I'm not getting any error message, but I have bad output. Look.
The left side not loads, but right yes. Why? Anybody please help me.