BadDaddy Posted January 26, 2011 Share Posted January 26, 2011 Hi So I have successfully set up a website and database where a user can create a listing and view listings on a listing details page. The viewing can only be done, however, only from either from either running a search query from the search form or from clicking one of the listings from the listing table. The listings are not being indexed from the search engines from the direct page, instead from the listing table which is about 3,000 listings, not very user friendly to land on this page and have to go through the table or use the table filter. Here's what I am trying to accomplish: A web page that has a dynamic presence / URL like a Wordpress page: http://www.mysite.com/listing_title/ The title of the page has the listing information in it: This page is about a $listing_title $listing_item listing number $listing_number that is online! Each individual Listing / page is indexed on the search engines and has a direct link to it I am familiar with PHP and have created this site but I am far from an expert! Please give me a code example or link to one because if you just say "do this to this and that" you will totally loose me. Thank you so much for any help. Quote Link to comment https://forums.phpfreaks.com/topic/225686-dynamic-page-creation-from-mysql/ Share on other sites More sharing options...
QuickOldCar Posted January 26, 2011 Share Posted January 26, 2011 I guess some link examples and how you are saving your current links in the database would help. Can use str_replace() and also lower them with strtolower(). The idea would be to replace all characters except for letters and numbers in the title url to a - or a _ but only after the sites name, so need to do it just for the actual link title and not the domain,path or script name Just post any information you have and see what we can do for you. Quote Link to comment https://forums.phpfreaks.com/topic/225686-dynamic-page-creation-from-mysql/#findComment-1165329 Share on other sites More sharing options...
QuickOldCar Posted January 26, 2011 Share Posted January 26, 2011 Gonna take a stab in the dark here and show you an example I just made. I didn't fully test it for all possible types, but seems to work, I'd test it though. <?php //function , can modify it more if need to function makePretty($title) { $title = trim($title); $title = str_replace(array(" "," ",","), '_', $title); $title = str_replace(array("'",'"'), '', $title); $title = strtolower(preg_replace('#\W#', '', $title)); $title = str_replace(array("__","___","____"), '', $title); return $title; } //some dummy info so i can do this $site_domain = "http://mysite.com/"; $titles = array("This is my cat","Wow That's awesome","Today's hottest ce-leb-ri-ties","You & her are @ the house","FOR SALE!!!!!","One,Two,Three...GO"); //my loop to show changes foreach ($titles as $title){ $pretty_title = makePretty($title);//makePretty function $permalink = "$site_domain$pretty_title"; echo "<a href='$permalink'>$title</a><br />"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/225686-dynamic-page-creation-from-mysql/#findComment-1165351 Share on other sites More sharing options...
QuickOldCar Posted January 26, 2011 Share Posted January 26, 2011 Just wanted to add , you should check for duplicate titles, and if have same title add a number to the end of url's in increments of +1 Quote Link to comment https://forums.phpfreaks.com/topic/225686-dynamic-page-creation-from-mysql/#findComment-1165354 Share on other sites More sharing options...
BadDaddy Posted January 26, 2011 Author Share Posted January 26, 2011 Thanks so much for the responses! It turns out that when I created the listing table that posted all the listings they are getting indexed because I made a link from the listing table that links to the listing details page. The url has a ?id=1003 instead of the listing name but that doesn't really matter since I tweeked the title, keywords and page description meta tags to post the listing title and listing item to romance the search engines. You guys are awesome! Thanks again for the help. I love PHP!!! Quote Link to comment https://forums.phpfreaks.com/topic/225686-dynamic-page-creation-from-mysql/#findComment-1165363 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.