I would suggest putting all the code before the loop into a object.
then run the string replace against the contents of it.
so something like this SHOULD do it.
PHP Code:
<?php ob_start(); echo 'ALL CONTENT which is displayed on the pages all the random crap blah blas'; echo 'dee dar DAN is the best DAN is typing random stuff!'; $page = ob_get_contents(); ob_end_clean(); $username = ' dan '; // Leave space other wise it will replace all instances of the letters "dan" $page_v2 = str_replace($username, '<a href="profile.php?user='.$username.'">'.$username.'</a>', $page); echo $page_v2;
One thing you should make note of is using ob_'s an be a pain when debugging as it dont collect PHP errors which can be a bit annouying.
So the above basically collects all the out put into a object and then does string replace on that objects contents replaces all username with that username in a link, and you can play with the link address to fit with what ever your current profile page format is.
now i would think if you wnated to make all the username in your db links. this should work...
PHP Code:
<?php ob_start(); echo 'ALL CONTENT which is displayed on the pages all the random crap blah blas'; echo 'dee dar DAN is the best DAN is typing random stuff!'; $page = ob_get_contents(); ob_end_clean(); $result = mysql_query("SELECT username FROM users"); $usernames = mysql_fetch_array($result); foreach($usernames as "$user") { $page_v2 = str_replace(" $user ", '<a href="profile.php?user='.$username.'">'.$username.'</a>', $page); } echo $page_v2;
This is untested but give it ago. replace the table and that info with what ever you need, and if the variables are already in use change them (on my code)
Please tell me if this works, and if it does TP will be greatly apprieciated 
__________________
Discounted Web Hosting With XDnet! >> Get 25% of hosting~ Promo: Webmaster-talk <<
Last edited by dansgalaxy; 09-23-2007 at 12:48 PM..
|