replace and covert to friendly url???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tech0925
Forum Commoner
Posts: 47
Joined: Wed Nov 09, 2011 2:46 pm

replace and covert to friendly url???

Post 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
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: replace and covert to friendly url???

Post by twinedev »

Code: Select all

<a href="fooddetail.php?id=<?php echo urlencode($thisId); ?>"><?php echo htmlspecialchars($thisName); ?></a>
tech0925
Forum Commoner
Posts: 47
Joined: Wed Nov 09, 2011 2:46 pm

Re: replace and covert to friendly url???

Post by tech0925 »

Thanks so much! You rock!! :mrgreen:
Post Reply