Last Items randomise products

snark

What would be very nice is THE option to mark an item to be displayed

Something like THE groups option in news so that you can decide what to display in an anyitem sort of snipper

daydreamer

Just as an after thought could'nt this be added to bakery as another addon module "Show Random Products"

Regards
Nick

daydreamer

Hi guys,

Many thanks for the help the first line seems to work fine, thanks Christoph

@crnogorac081

I replaced with you your to try that and it shows syntax error but I'm not sure why as I'm not a coder

Many Thanks
Nick


crnogorac081

#3
I belive that the replaced line would display random X rows from items (ordered descending by any DB field name), and not LAST X rows

Try to adjust your code to

$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY modified_when DESC LIMIT ".$num_items);
while($row = $query_items->fetchRow())
{
// Display and style your block here
$results2= "item id: ".$row['item_id']." title: ".$row['price']." link: ".$row['link']." description: ".$row['description']." image: ".$row['main_image'];

//THIS FUNCTION WILL SHUFFLE ORDER OF YOUR LAST ROWS SELECTED FROM DB
shuffle($results2);

// display array of items..
echo $results2;


Christoph may help you find the line where to insert shuffle function..

cheers
Web developer

freeSbee

Hi Daydreamer

Test this:
Replace about line 113 of the include.php file
$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY modified_when DESC LIMIT ".$num_items);

by
$query_items = $database->query("SELECT item_id, title, price, link, description, main_image FROM ".TABLE_PREFIX."mod_bakery_items WHERE active = '1' AND title != '' ORDER BY RAND() DESC LIMIT ".$num_items);


Be aware that this can take a large amount of processing time for table of more than 500 rows.

Regards Christoph

daydreamer

I know Last Items shows the latest added products first, is there anyway to make them randomise each time the page loads.
Thanks