General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 28th, 2003, 11:52 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 117 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
remove tags

Hi guys,

currently in my database, i have a column where they store bookmark html code
e.g: <a name="dddda"></a>

actually i wanna remove all all the html tags and only display the ddda in a textfield to the user.. the prob is how can i remove the html bookmark tags ?

I did think of using strip_tags function.. but what should i put at the end of the function ? is it <a name=""></a> ?? this doesn't make sense to me.. is there any other way i can do this ?


PLease advise.

Reply With Quote
  #2  
Old November 29th, 2003, 10:53 AM
dotcomma dotcomma is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: New Zealand
Posts: 20 dotcomma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
What I would do is I would use PHPMyAdmin to export that table to a file, open that file in a text editor and do Replace <a name=" with nothing. Then run the Replace again, this time replacing "></a> with nothing.
Save the file, then in PHPMyAdmin run that file as SQL.
And voilą...

Hope this helps,

Toine

Reply With Quote
  #3  
Old November 30th, 2003, 08:37 PM
Alicia Alicia is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 117 Alicia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 30 m 29 sec
Reputation Power: 6
I want to show the value of the row to the users(except the html code) and not edit by myself..

any idea ?

Reply With Quote
  #4  
Old November 30th, 2003, 09:49 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
Although it may be too late for this suggestion, but re-designing your table might be a good option...

For example, a table called "Bookmarks" with the fields "url" and "label"...

Other than that, I suppose there's way to strip the attributes out of HTML using an XML parser (pre-built into PHP)
Reference: http://ca2.php.net/manual/en/ref.xml.php

From what I understand, the strip_tags function will simply strip any existence of <tag> in a string... You can't extract information before it does so.

Reply With Quote
  #5  
Old November 30th, 2003, 10:37 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 14 m 9 sec
Reputation Power: 8
I took the liberty of creating some code to parse the HTML...
I made a basic parser that will strip the value of the HREF attribute in the A tag...
This is basic stuff, read the reference link i provided in my previous post for some further examples.


PHP Code:
<?php

    
// This function will be run when a tag starts
    
function startElement($parser$tag$attrs) { 
    if (
$tag == "A") { 
            print (
$attrs['HREF']);
    } 
    }

    
// This function will be run when a tag ends
    
function endElement($parser$tag) {
        return;
    } 

    
// This is the link that we want to parse
    
$data '<a href="http://www.devarticles.com/">This is a link to devarticles</a>';

    
// Create the parser
    
$xml_parser xml_parser_create();

    
// Tell parser which functions to use
    
xml_set_element_handler($xml_parser"startElement""endElement"); 

    
// Parse the text
    
xml_parse($xml_parser$data);

    
// Close the parser
    
xml_parser_free($xml_parser);

?>



Note, to put the value in a text field, change the print line within the startElement function to the following:
print ("<input type='text' value='".$attrs['HREF']."' size='50'>");

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > remove tags


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 5 hosted by Hostway
Stay green...Green IT