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
https://forums.phpfreaks.com/topic/80504-solved-search-my-site/
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
https://forums.phpfreaks.com/topic/80504-solved-search-my-site/#findComment-408228
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
https://forums.phpfreaks.com/topic/80504-solved-search-my-site/#findComment-408257
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
https://forums.phpfreaks.com/topic/80504-solved-search-my-site/#findComment-408387
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
https://forums.phpfreaks.com/topic/80504-solved-search-my-site/#findComment-409175
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.