Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplaying random product in a related product table of 5
    text
    copied!<p>I am creating a row of "product related table of x5" and using MYSQLcode RAND to generate RANDOM products and a exception clause using id!='$id' - where id is existing product that is being viewed currently.</p> <p>However the problem is that all the product images generated were all of the same similar product image. Can anyone shed some light on this? </p> <p><a href="http://i.imgur.com/zTvSwNm.jpg" rel="nofollow">Pic</a> for better reference: </p> <pre><code>include "MyOnlineStore/storescripts/connect_to_mysql.php"; $sql2 = mysql_query("SELECT * FROM bag WHERE id!='$id'ORDER BY RAND()LIMIT 5"); $productCount2 = mysql_num_rows($sql2); // count the output amount if ($productCount2 &gt; 0) { ?&gt; &lt;table border="1"&gt; &lt;tr&gt; &lt;?php while ($row2 = mysql_fetch_array($sql2)) { $idrelated = $row2["id"]; $imagerelated = $row2["image"]; $titlerelated = $row2["title"]; } } else { echo "That item does not exist."; exit(); } mysql_close(); </code></pre> <p>HTML</p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;td&gt; &lt;a href="http://example.net/product.php?id=&lt;?php echo $idrelated; ?&gt;"&gt; &lt;img src="admin/product/uploaded_files/&lt;?php echo $imagerelated; ?&gt;" width="100" height="100" alt="&lt;?php echo $titlerelated; ?&gt;" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;a href="http://example.net/product.php?id=&lt;?php echo $idrelated; ?&gt;"&gt; &lt;img src="admin/product/uploaded_files/&lt;?php echo $imagerelated; ?&gt;" width="100" height="100" alt="&lt;?php echo $titlerelated; ?&gt;" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;a href="http://example.net/product.php?id=&lt;?php echo $idrelated; ?&gt;"&gt; &lt;img src="admin/product/uploaded_files/&lt;?php echo $imagerelated; ?&gt;" width="100" height="100" alt="&lt;?php echo $titlerelated; ?&gt;" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;a href="http://example.net/product.php?id=&lt;?php echo $idrelated; ?&gt;"&gt; &lt;img src="admin/product/uploaded_files/&lt;?php echo $imagerelated; ?&gt;" width="100" height="100" alt="&lt;?php echo $titlerelated; ?&gt;" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;td&gt; &lt;a href="http://example.net/product.php?id=&lt;?php echo $idrelated; ?&gt;"&gt; &lt;img src="admin/product/uploaded_files/&lt;?php echo $imagerelated; ?&gt;" width="100" height="100" alt="&lt;?php echo $titlerelated; ?&gt;" /&gt; &lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload