Jump to content

Dynamic Page Creation From MySQL


BadDaddy

Recommended Posts

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.

 

 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 />";

}
?>

Link to comment
Share on other sites

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!!!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.