Quote:
| Originally Posted by requinix If $repeated is false then $x never increments. I think. |
The problem is with the $p = 1; at the beginning of the loop. I don't know why is messing everything up. I cant find the error i am happening you guys could spot it. If i place the $p = 1; outside the loop everything works but i get repeated items which is what i want to stop from happening.
<?php
$count = mysql_query("SELECT COUNT(xx_ID) FROM table");
$max = ceil(mysql_result($count, 0));
$x = 1;
while ($x <= 8){
$repeated = false;
$p = 1;
$random[$x] = rand(8001,8000 + $max);
while ($p <= $x){
if ($random[$p]==$random[$x])
$repeated = true;
$p++;
}
if (!$repeated){
$query = mysql_query("SELECT * FROM table WHERE xx_ID='$random[$x]'");
$query_row = mysql_fetch_assoc($query);
if ($x == 1 || $x == 5)
echo "<div>";
echo "<div>";
echo "<img alt='' src='ssl/Product_Images/".$query_row['pictureName'].".jpg'/>";
echo "<a href='Products.php'><p>Item: ".$query_row['item']."<br/>Condition: Refurbished<br/>".$query_row['model']."</p></a>";
echo "<p>$".$query_row['price']."</p></div>";
if ($x == 4 || $x == 8)
echo "</div>";
$x++;
}
}
?>