PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 16th, 2002, 03:06 AM
nghfoeth nghfoeth is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 nghfoeth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mysql madness

I've a bit of a problem here, and I am hoping someone can help me here.

I've got a simple database with a simple table in it that contains nothing but content. The client wants to be able to edit this content. That's fine, that's all working properly. She's not savvy, however, and doesn't want to learn anything about linking. The question is this: is there a way to dump the data from a field (the field is "content") to the page, processing it such that if a word exists (like "%link|linkword" for example) in the query, how can I make PHP create a link out of that (in the place it is pulled from in the content) such that it displays as...
Code:
<a href="index.php?page=$page&sub=$link>linkword</a>


So far I've tried using explode and implode (each word dumped into an instance of $array) to dump it all into an array and search that array for instances where the word begins with %, and I can't seem to get it right.

Any insight?

Reply With Quote
  #2  
Old October 16th, 2002, 04:38 AM
htmlartist htmlartist is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX USA
Posts: 18 htmlartist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to htmlartist
RE: mysql madness

I think you would need a character marking the beginning and ending like this: %link|linkword%. I believe the function eregi_replace() is what you are looking for, however I lack the regular expression knowledge to code one up for you Go check it out at php.net or maybe someone here will be nice and code out an example for ya.

Reply With Quote
  #3  
Old October 16th, 2002, 10:53 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: mysql madness

Try this:
php Code:
Original - php Code
  1. <?
  2. $content = "Here is some content. Here is a sentence with a %link|linkword in it.";
  3.  
  4. $content = preg_replace("/%(S*)|(S*)/is", "<a href="index.php?page=$page&sub=$1>$2</a>", $content);
  5. echo $content;
  6. ?>

Reply With Quote
  #4  
Old October 16th, 2002, 11:49 AM
htmlartist htmlartist is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Houston, TX USA
Posts: 18 htmlartist User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to htmlartist
RE: mysql madness

man, i gotta learn to do those Perhaps someone can point me towards a tutorial?

Reply With Quote
  #5  
Old October 17th, 2002, 02:26 AM
nghfoeth nghfoeth is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 3 nghfoeth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: mysql madness

Thanks a lot. That worked great. Regular expressions have always killed me, so I always try to find a different way to do things.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > mysql madness


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway