fonecave Posted December 6, 2007 Share Posted December 6, 2007 Hi guys, I know there are loads of sites and code snippets out there but i want to create my own, I have got a webpage with a thumbnail and a text link underneath it, I want something that will search the page by a keyword and find all the appropriate thumbnails and links and put them in a php page lined up next to each other, how do i go about it? can anyone start me off? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 You will want to use LIKE in your query, so something like this SELECT * FROM table WHERE keywords LIKE '%$keyword%' Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 that means nothing to me im afraid i have no table just a webpage with thumbnails and respective hyperlinks i dunno where to start at all Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 its really divs i need to search for i think as the div for the thumbnail contains the keyword to search for. I have no mysql database tho i could use a txt file? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 Yeah, your going to need a database for this. Are you able to have a database with your hosting? Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 nah i dont any other way? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 Does your host support PHP at least? Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 yes PHP we do have! web site is at www.fonecave.com if you go to themes they are what i want to be searchable Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 How do you have a login/register on your site without a database? Well...I'm not sure if there is that much you can do in your situation without a database. I would suggest looking at your host seeing if you can upgrade to be able to have one. It would be pretty difficult using a text file for your search. Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 i loop through a text file quite easily for the login, cnt i do the same thing? Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted December 6, 2007 Share Posted December 6, 2007 You can probably use a text file...but it will be a lot harder and less efficient depending on how much information you store. You could set it up something like this: avatar_img avatar_url keyword, keyword, keyword, keyword, keyword, keyword, keyword, keyword, keyword, keyword I'm not very experienced with working with flat files, so that might not be the best way...if you have already done this with your login, what are you having problems with? Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 6, 2007 Author Share Posted December 6, 2007 i will have to give it a try have a look on the site in a few days and see how it goes any other suggestions welcome Quote Link to comment Share on other sites More sharing options...
Distant_storm Posted December 6, 2007 Share Posted December 6, 2007 You want to search within a page ??? use cntrl F haha Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 7, 2007 Author Share Posted December 7, 2007 i have decided to index the themes in a text file and have wrote code to preg match the searched phrase to the keywords in the text file and i can get a match fine when the php finds a match in the keywords, how do i get it then to add the object to the php page? <?php error_reporting(0); if (isset ($_POST['submit'])) { $keyword=$_POST["keyword"]; $searchlen=strlen($keyword); $match="false"; if (empty($keyword) || ($searchlen<4)) { echo '<form method="POST" action="http://fonecave.110mb.com/themesearch.php"'; echo ' enctype="multipart/form-data">'; echo '<input type="text" name="keyword" size="20">'; echo ' <input type="submit" name="submit" value="Search">'; echo '</form>'; echo 'Search must be over 3 characters'; die; } else { $file=fopen("privatefile.txt","r") ; if ($file) { while ( !feof($file)) { $line1 = trim(fgets($file)); $line2 = trim(fgets($file)); $line3 = trim(fgets($file)); if (preg_match("/$keyword/", $line3)) { $match="true"; } } } } } echo '<form method="POST" action="http://fonecave.110mb.com/themesearch.php"'; echo ' enctype="multipart/form-data">'; echo '<input type="text" name="keyword" size="20">'; echo ' <input type="submit" name="submit" value="Search">'; echo '</form>'; echo $match; ?> Quote Link to comment Share on other sites More sharing options...
fonecave Posted December 7, 2007 Author Share Posted December 7, 2007 Have built it on a text file that contains the information instead of a database have a look at www.fonecave.co.uk goto themes and search for "test" or the themes that can be found in the two catagories there aren't many at the minute have only just set it up, if you want to know how ive done it send me an email thanks for your help andy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.