Forum Moderators: coopster
http://example.com/page-title.html
This may be a bit hard to explain so I'll give an example:
MySQL Database Structure:
id ¦ seo ¦content
1 ¦ page-title ¦ the page content here
2 ¦ page_no_2 ¦page #2's content here
etc...
Someone goes to http://example.com/page-title.html (I have the htaccess code etc setup for all this).
The script gets the variable "page-title" from the URL and does a mysql search to find the content of that page.
I want to avoid using the id for this as it just seems cleaner to me to use something like above rather than domain.com/1/page-title.html
Now my real question is whats a better thing to do:
- Run 2 queries, the first something like:
"SELECT `id` FROM table_name WHERE seo = 'page-title' LIMIT 1"
and then get the ID and do another query:
"SELECT * FROM table_name WHERE id = '1' LIMIT 1"
To get the rest of the items from the database?
Or should I just do the first query and get all of the information I need from that?
("SELECT * FROM table_name WHERE seo = 'page-title' LIMIT 1")
Thanks! (Any other ideas on how I can optimize the above would be great too!)
[edited by: coopster at 6:22 pm (utc) on Feb. 16, 2009]
[edit reason] please use example.com, thanks! [/edit]