Page 1 of 1

replace and covert to friendly url???

Posted: Wed Jan 11, 2012 1:39 pm
by tech0925
Hello,

I ran into an issue while trying to validate my website. I am converting the title of a food into the url for seo reasons. The issue I have is that if the title has a symbol, for example, the & sign it does not validate obviously. How can I convert the title into friendly links? The link is stored in a variable and somehow needs stripped and replaced. Here is how I am calling it...

This stores the link or title:

Code: Select all

$thisName = MYSQL_RESULT($result,$i,"name");
Next this displays it on the page to be clicked:

Code: Select all

<a href="fooddetail.php?id=<?php echo $thisId; ?>"><?php echo $thisName; ?></a> 
So I am assuming somewhere in-between these two codes and need to perform some sort of strip but I don't know how to do that. Any help would be greatful! Thanks!! :D

Re: replace and covert to friendly url???

Posted: Wed Jan 11, 2012 1:48 pm
by twinedev

Code: Select all

<a href="fooddetail.php?id=<?php echo urlencode($thisId); ?>"><?php echo htmlspecialchars($thisName); ?></a>

Re: replace and covert to friendly url???

Posted: Wed Jan 11, 2012 2:25 pm
by tech0925
Thanks so much! You rock!! :mrgreen: