PDA

View Full Version : Ideas needed on how this ordering can be achieved


cinq
02-17-2005, 08:32 AM
Would like to showcase the following on the main links page.

Latest links
Most popular links
Random link

Each of these would be a block on the main page.
They would probably require 3 different queries.

My question is how can I achieve this :

I can set in the Admincp option : display orders for each block, such that I can arrange which block appears first, second and third.

Any ideas would be most appreciated :D
Thanks

trafix
02-17-2005, 09:25 AM
look at the coding for the jukebox .... it has most of that for playing defult song ;)

cinq
02-17-2005, 09:33 AM
I did a quick scan, I presume you mean the part below

//start load the song

of the vb_jukebox.php file ?

Don't really think it does what I seek ?

trafix
02-17-2005, 09:44 AM
Most popular links
this finds the most played song

$mostplayed = $DB_site->query_first("
SELECT *
FROM " . TABLE_PREFIX . "vb_jukebox_trax
WHERE active = 1
ORDER BY plays
DESC LIMIT 1
");


Random link

$getimage = $DB_site->query_first("
SELECT *
FROM " . TABLE_PREFIX . "vb_jukebox_trax
WHERE active = 1
ORDER BY RAND() DESC LIMIT 1
");

cinq
02-17-2005, 09:47 AM
I know the query to get the stuff i need :p

What i mean is how could I order the blocks that shows these stuff ( latest, random, most popular ) based on changeable settings for display orders in the Admincp. :)

edit: p.s I think order by rand() desc makes no sense :) just order by rand() will do.

sabret00the
02-17-2005, 09:54 AM
seriously i'd just suggest adding a column to the table "block_order" and then ORDER BY links.block_order

cinq
02-17-2005, 11:46 AM
Hmm, isn't there another means ?

Dean C
02-17-2005, 12:26 PM
I wouldn't use queries for this. Use vBcron and cache the info every x hours :)

cinq
02-17-2005, 12:32 PM
You lost me there, Dean :)

sabret00the
02-17-2005, 02:42 PM
the only other way i can think of cinq is to do something like set it up in the vboptions so you can have the blocks orders then in your code set em out as an array, then cycle through the array with a while, using the block id's to set the order

i.e.
vboptions[blockorder1]
vboptions[blockorder2]
vboptions[blockorder3]

ok this may be impossible without a query but use a function to arrange them in numerical order as an array

numorder[array] //would look something like = "3, 1, 2"
ofcourse for that you'd need to assume your instructions dictate that which block is which number in the array

anyway from there

while($order = $numorder[array])
{
$block .= "$order[blockid]";
}

i can't explain it but chances are if i wanted to do what you're trying that'd be what i'd try.

cinq
02-18-2005, 05:39 AM
Thanks for trying to explain it sabe but I still don't quite get it :(
I'm still drawing a blank at how I should do this :(