AFTER a query for 1 category I receive details back. 1 category can have more items. The items have sequental id's but not in normal order.

While (category_items()) {
echo item_id(); // checking this give me for example id 1, 3 and 5.
}

I want to select one random item_id from these results.
Without adjusting the query itself.
Something like item_id() == 3 perhaps?
Is that possible?

Recommended Answers

All 9 Replies

what exactly do you want to manipulate?Please be more descriptive so that we can help.

In the While (category_items()) { loop I echo item_id();
it give me 1 or more results. Example: 1, 3 and 4.
I want to pick one from those and say something like item_id() == 3.
Then when I echo item_id(); I would see "3".

btw: How do I get all results from this query visible to see what I can do with it?

osc_query_item(array('category' => osc_category_id(), 'page' => 0, 'results_per_page' => 3)) ;
Member Avatar for diafol

@mjsmitten

You have not described your problem adequately. Also you're using custom functions, which we have no idea how they work. You don't show your query. What are you querying an array or a db??

Listen, I am kinda new to this site. How do I edit my first topic so I can put the code in there?

Member Avatar for diafol

You can't after 30 minutes, just place your code into a new post.

Well, if possible delete this topic, I already used another one with all the code inside. Thanks !

Member Avatar for diafol

Well, if possible delete this topic, I already used another one with all the code inside. Thanks !

No not possible. Other contributors have made an effort to reply to you. You shouldn't start duplicate threads, that just ends up annoying members. If you supply the link here, we can then direct people to the other thread. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.