Alright... this is another issue with a terribly designed database schema... just looking for some advice. I am using pretty urls in a directory I am building, but I have to use the category names as my where clause because categories don't have ids in the terrible schema. So... I am using the function I found in scottay's thread about pretty urls...
static public function cleanUrl($url) {
return
preg_replace('/[^a-z0-9-]/','',
preg_replace('/\s{1,}/','-',
preg_replace('/&/',' and ',
strtolower($url)
)));
}
This works exactly how I would like it to... but the problem now is that I can't search my database for a category like "health-foods-and-servicesnutritional-products" when in the database it's called "Health Foods & Services/Nutritional Products". Would it be a better idea to create an extra column in the table with the url-safe version of the category to search in... or should I just create a function that matches the url-safe category names to the ones in the database... or am I going about this wrong all-together?
Not that my opinion should count too much, since I'm very new to php, but I was dealing with a similar issue just the other day.
I decided to add an extra column and make my life a lot easier. I don't think I'm losing a lot of space on my hosting because of it, but I feel more relaxed coding this way.