The above function selects random rows from a certain table. What I need to do is restrict the rows which can be selected by putting in an additional condition based around the "category_id" field of the table, but I don't honestly think I can work out how to do this myself with my limited knowledge.
There are two other tables I know will need to be referenced in the above function. One is "categories" and another is "users"...
I know that in the categories table there will be two relevant fields: "minimum_age" and "category_id", and in the users table there will be two relevant fields: "user_id" and "show_adult".
If the currently logged in user's database entry has a value of 0 in the "show_adult" field then when the above function selects random rows it needs to exclude any rows where the "category_id" is matched to the "category_id" in the categories table and the corresponding "minimum_age" in the categories table has a value of 18. Whereas if the currently logged in user's database entry has a value of 1 in the "show_adult" field then the above function should run as it currently does.
Although I pretty much understand what the code needs to do, how to write it is beyond my current knowledge (I could probably write it in BASIC though haha!). Any help greatly appreciated.
EDIT: I realise the above function probably uses other custom functions within it that cannot be seen above, but I figure those shouldn't be relevant for making the changes I need.
Last edited by tr0ub1es0me; 07-02-2012 at 03:49 PM.