![]() |
Category and order
Hello all!
I'm new here, yea this looks like i'm just fishing info and leaving.. Well it doesn't have to be so. Ok what ever. My problem is this: I have an ad website under developement and it has multiple gategories where same ad can be. But the order is always different. So how could this have been done? I have idea like this in mysql tables: -- Categories -- id category (the name like sport, horses, dogs...) order (helds numbers wich will be the ids of ads.) -- Ads -- id name url image width height colspan category My function will use this -> Mainos('category'); So it will print all ads in order wich is told in category table in order row of the category. And it will start new row allways after colspan total = 3 I hope someone understood what I asked and is able to help me :) Thank you. Regards, Jonne ---> |
I honestly did not understand one thing that you said...
[edit] Ahh, nevermind. I see what you mean now. Well I am not exactly sure how to do this in one query, but you would just run a query to fetch the category, and then use another query to fetch the ads from that category. PHP Code:
|
I'm not sure on the question, but would this post by me help you at all?
http://www.talkphp.com/showpost.php?p=5123&postcount=3 |
Quote:
Category Table: categoryID categoryName categoryAdsOrder Ads Table: adID adCategoryID adField adField1 He wants to select all the ads from a specific category and list them in the order defined in categoryAdsOrder |
Quote:
I'll try Chaoses way. Ill inform you little bit later :) |
You could do this all in one query if your table were normalised. Try reading the post I posted a link to above - and have a lookup table.
|
Quote:
I tested now your way to do it and well firstly it gave me 3 errors, about first mysql_fetc_assoc, well repaired that. Also it gave error that implode has bad arguments and it also yelled me about the last mysql_fetch_assoc function. PHP Code:
I tried it like this -> Code:
SELECT |
| All times are GMT. The time now is 07:15 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0