Jump to content

[SOLVED] search my site


fonecave

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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;
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.