I have a table
items
id int unsigned auto_increment primary key,
name varchar(255)
price DECIMAL(6,2)
I want to get at least 30 random ite
then do the following code
$arr = array();
$num = 0;
while($row = mysqli_fetch_array($result))
{
array_push($arr,$row['id']);
}
$arr2= array();
while(count($arr2!=30)
{
$cnt = random(0,count($arr));
if(in_array($arr[$cnt],$arr2);
{
array_push($arr2,$arr[$cnt]);
}
}
print_r($arr2);
here $arr2 is the required array