proggR Posted July 30, 2008 Share Posted July 30, 2008 I know its bad netiquette to double post but I've already posted this once in the MySQL section and can't delete it from there. I'm about to write up the pseudo code to change my site from text based entry storage to a database and I've just thought of something that I'd like to add now if I could to make things easier. A search bar. The way the text files work, which is the same way the database will work, is that posts are entered as html files (they have the .php extension but have no php code.. I may change that but don't necessarily need to) and the db/text file stores the filename so that they can be included into the main page. Since I have it setup this way searching it, AFAIK, would be kind of hard. So I was thinking that in my updating page I could just add an extra column in which the code entered is also uploaded and then when I go to search I could use SELECT filename, entry FROM table WHERE entry='%searchterm%' or something to that effect. Since its formatted as an html file would that screw things up with this? Or perhaps theres a way to strip the html tags from it and just upload the content to the db for searches? Sorry again for posting it twice. I'll mark it as topic solved in both posts if it gets solved. *edit* I've found strip_tags() and that could be useful. Could someone explain how I could remove all the pre-content sections of the html code (head element and meta tags). Thanks. Link to comment https://forums.phpfreaks.com/topic/117388-adding-a-searchable-feature/ Share on other sites More sharing options...
genericnumber1 Posted July 30, 2008 Share Posted July 30, 2008 Assuming your html is formatted properly you can use regex to pull the content between the <body> tags, and then use striptags to take off the rest of the html. Granted I have no idea how one of these html pages is formatted or anything like that so I can't give you an exact answer. Link to comment https://forums.phpfreaks.com/topic/117388-adding-a-searchable-feature/#findComment-604043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.