Adding Page Title To Dynamic URL

First post so hi everyone first of all!
Im in need of some help…
I have a menu that I’ve setup to dynamically create links from my database (mysql)



<?php
mysql_connect("********","*********","**********") or die(mysql_error());
mysql_select_db("watch") or die(mysql_error());
      $query = mysql_query("SELECT * FROM watch ORDER BY time")
   
      or die(mysql_error());    
   
      while($row = mysql_fetch_array( $query )) {                   
   
        {
   
           $id = $_GET['id'];
		 
        }   
      echo "<div class=\\"collapsed\\"> <span class=\\"rss:item\\">";
                
               
                echo $row['time'];
                echo " - ";
                echo $row['match'];
                echo "</span>";
               if($row['1'])  echo "<a href=\\"http://www.site.com/folder/1/{$row['id']}.html\\" target=_blank>Link 1</a>";  else echo "" ;
             
                               
                echo "</div>";
        }
  
      ?>

now what I’d like to do is add the title of the page into the URL like:

Question is, I’m somewhat of a php noob and struggling to implement it, I cant work out where to put the code, how to make the title all lowercase for the URL, and add a “-” instead of a space…

Can anyone help me out at all?
Ive read that it can be done via .htaccess or both, but apparently the best way is php…?

You can do the URL in PHP, but the server will have to be configured with modrewrite in your htaccess file

Heres a good beginners forum with modrewrite info

Mod_Rewrite Forums • View forum - mod_rewrite

For the PHP side, just pick your title out of the database, apply strtolower() to get rid of the capitals, then use preg_replace() to change all spaces to dashes.

thats great, thanks for your help, will take a look at it now! :slight_smile:

stupid question but where would i place

$strtolower
&
preg_replace()

within the php?