function create_url($id) {
// get your record from the database
mysql_select_db($connect, $dbconnect);
$query_Recordset_getcontent = "SELECT * FROM pages WHERE pages_menu_display = '$id' LIMIT 1";
$Recordset_getcontent = mysql_query($query_Recordset_getcontent, $dbconnect) or die(header("Location:problems.php"));
$row_Recordset_getcontent = mysql_fetch_assoc($Recordset_getcontent);
$totalRows_Recordset_getcontent = mysql_num_rows($Recordset_getcontent);
// put in new variable and trim whitespace from ends
$string = trim($row_Recordset_build_main_menu['pages_menu_display']);
// replace all dashes, underscores and spaces with just dashes
$string = preg_replace('#[-_ ]+#', '-', $string);
// make url
$url = "http://www.yourwebsite.com/$string.html";
// return url
return $url;
}
// here's how you may use the function
// (where 1 is the id of the link your creating
create_url(1);
// please let me know if you have any questions
|