Jump to content


Category problem


6 replies to this topic

#1 Jonne

    Young Padawan

  • Members
  • Pip
  • 8 posts
  • Gender:Male
  • Location:Finland
  • Interests:Floorball, PHP, Discovering new things!

Posted 23 November 2007 - 04:34 PM

Hiya, I was friendly and just edited this old post what was about this same function, but the problem I asked was solved well now I have another problem.

Now it is about MySQL... I'm not really good in MySQL so I ask for help in this mayby really easy thing.

Let's make an example now of this what I want to do:

Database -> Has ADs with multiple categorys in one ad.

Website -> Will print all ADs in the specific category with function ad('sport');

Lets say we have google ad there and I want it to be displayed in Sport, Events, Search pages categories.

Ok I would like to know do I need to create categories table seperately or can ad table handle different options in category field?

Ask if you didin't understand anything about this... :friends:

Edited by Jonne, 24 November 2007 - 02:24 PM.


#2 curthard89

    Young Padawan

  • Members
  • Pip
  • 226 posts

Posted 25 November 2007 - 04:52 PM

could just have the cats in one field of the ad seperated by something and then explode it, and check for the right cat?

#3 Jonne

    Young Padawan

  • Members
  • Pip
  • 8 posts
  • Gender:Male
  • Location:Finland
  • Interests:Floorball, PHP, Discovering new things!

Posted 25 November 2007 - 05:59 PM

View Postcurthard89, on Nov 25 2007, 11:52 PM, said:

could just have the cats in one field of the ad seperated by something and then explode it, and check for the right cat?


Thats what I frist thinked also, but havn't really never parsed the text.
Mayby it is time to take a look of it..

How this could be done?
If I have like in cat row this : sport:favourite:eating:humors or something like that..
then how it is really being searched from database and get the needed things to function?

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 November 2007 - 12:25 AM

Use the LIKE statement with the '%' wildcard.

http://dev.mysql.com/doc/refman/5.0/en/str...-functions.html

#5 Jonne

    Young Padawan

  • Members
  • Pip
  • 8 posts
  • Gender:Male
  • Location:Finland
  • Interests:Floorball, PHP, Discovering new things!

Posted 26 November 2007 - 05:42 AM

Oh ok. Thank you alot.. By the way...
I forgot to tell you that they also have different orders in different categories.. How that could be done?
So like in sport -> 1 humor -> 3 eating -> 5 and so on..
It would be easy IF they were only on one category... but well.. They are in many..

Edited by Jonne, 26 November 2007 - 06:23 AM.


#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 26 November 2007 - 05:53 PM

Off the top of my head, i couldn't think of an easy way to do that. If you had some sort of logical sorting method you used (like alphabetical order), that'd be something. But if it is relatively random and manual, that's different.

The only brute-force method i can think of in the later case there would be to use a relations table that had individual columns for each category. But that would get really ugly really fast, and i would advise against it (of course, in the end, a slightly more elegant form may be the only option).

#7 Jonne

    Young Padawan

  • Members
  • Pip
  • 8 posts
  • Gender:Male
  • Location:Finland
  • Interests:Floorball, PHP, Discovering new things!

Posted 27 November 2007 - 12:39 AM

View Postrc69, on Nov 27 2007, 12:53 AM, said:

Off the top of my head, i couldn't think of an easy way to do that. If you had some sort of logical sorting method you used (like alphabetical order), that'd be something. But if it is relatively random and manual, that's different.

The only brute-force method i can think of in the later case there would be to use a relations table that had individual columns for each category. But that would get really ugly really fast, and i would advise against it (of course, in the end, a slightly more elegant form may be the only option).

Thanks pal a lot still..
The order is simply made by sentence "it looks good now" . In the ad business there are still some things that you have to remember and one of them is how to output your websites and the ads in it. Also because these ads all have been paid so they have to be in some order to make even customers happy. Would you like to play 50€ a month when your ad is in the last box in whole website? I bet you wouldn't.

Ill try to research this method.. Mayby a one change is to make those 2 different tables where in category table there are the "order" and it contains all id's from the table customers where are the specific id for the caategory... You never know :huh:

Thanks again.. :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users