PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I got a full working script that I need to do some changes but I am not sure how to do it.
It actually take 3 ramdom items in the whole product list.
What I want to do is to take 3 random items of random subcategorie but from a specified categorie.
Thanks for the help!!!
//get 3 random products
$q1 = "select devbg_products.*, devbg_categories.*, devbg_subcategories.* from devbg_products
left join devbg_categories on devbg_products.ItemCategory = devbg_categories.CategoryID
left join devbg_subcategories on devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID
order by rand() limit 0,4 ";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) == '0')
{
$NoItems = "<center>You have no items at the database!</center>";
}
else
{
Thanks
-Musson
Last edited by Benjamin on Fri Jun 12, 2009 5:50 pm, edited 1 time in total.
Reason:Added [code=php] tags.
I'd be happy to help, but I'm not going to do all the work for you
If you can write that little bit of code (or at least try to) then I'll show you how to use it to answer your question.
Or you can wait to see if somebody else here gives you the answer.
//get 3 random products
$q1 = "select devbg_products.*, devbg_products.ItemCategory=26, devbg_subcategories.* from devbg_products
left join devbg_categories on devbg_products.ItemCategory = 26
left join devbg_subcategories on devbg_products.ItemSubcategory = devbg_subcategories.SubcategoryID
order by rand() limit 0,3 ";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) == '0')
{
$NoItems = "<center>You have no items at the database!</center>";
}
else
{
while($a1 = mysql_fetch_array($r1))
{
$MyPrice = number_format($a1[ItemPrice], 2, ".", "");