jigsawsoul Posted March 22, 2010 Share Posted March 22, 2010 my while loop is only displaying one database result, but i don't see why... any help guys? $result = "SELECT * FROM products LIMIT 0, 4"; $result = mysql_query ($result) or die (mysql_error()); $i=0; while($row = mysql_fetch_assoc($result)) { if($i%2) $divclass = 'otherbox'; else $divclass = 'otherbox MRright'; $products = ' <div class="'.$divclass.'"> <div class="productName">'.$row['title'].'</div> <div class="productDetails"> <div class="smallPic"><img src="_img/products/'.$row['image1'].'" alt="" width="122" height="81" /></div> <div class="smallPicDetails"> <h2>Product Descirption</h2> <p>'.substr($row['description'], 0, 35).'... <a href="product.php?id='.$row['id'].'">read more</a></p> </div> <div class="spayholder"> <a href="#">Add to Cart</a> <p>£ '.$row['price'].'</p> </div> </div> </div> '; $i++; } Quote Link to comment Share on other sites More sharing options...
scvinodkumar Posted March 22, 2010 Share Posted March 22, 2010 you should concatenate result in the while loop or just echo the result instead of storing in the variable and then displaying, like in the while loop $products .= Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.