[SOLVED] Search engine links

This is a discussion on "[SOLVED] Search engine links" within the PHP Forum section. This forum, and the thread "[SOLVED] Search engine links are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Nov 22nd, 2007, 20:26
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] Search engine links

Anyone now any good search engine tutorial websites??? I have never found it hard to find anythink on google butthis has put me through my paces!

I have found a few and there is either a bit of code with no form, or loads of code without the use of lamens terms & still no form, just a good old tutorial...

Alex geek sent me a good one, but i found it a little bit difficult to understand, there was no form or database to give me a idea of how it works!!

Any help would be great!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Nov 22nd, 2007, 20:39
Marc's Avatar
Staff Manager

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Posts: 1,786
Thanks: 0
Thanked 16 Times in 16 Posts
Re: Search engine links

I found this: http://www.roscripts.com/PHP_search_engine-119.html useful. Hope you do too.
__________________
Marc
Staff Manager - Webforumz.com


Want to be a moderator? PM me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Nov 22nd, 2007, 20:56
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

I've never understood why you would write your own search engine, when you can just use Google CSE.

You're most unlikely to create as effective a search engine as Google.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Nov 22nd, 2007, 21:04
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Search engine links

Because google's search engine can take days to index a new page.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Nov 22nd, 2007, 21:11
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Quote:
Originally Posted by alexgeek View Post
Because google's search engine can take days to index a new page.
And you can't wait that long?

I suppose this could be important for large news sites, but most people can surely wait a few days.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Nov 22nd, 2007, 21:17
alexgeek's Avatar
Moderator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,812
Blog Entries: 9
Thanks: 2
Thanked 2 Times in 2 Posts
Re: Search engine links

Me personally? Nope. I'd rather do the search function myself and it be there as soon as I post it.
Plus this is experience!
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Nov 22nd, 2007, 21:33
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Perhaps if I were skilful with PHP, I'd see this differently.

But in any case, I'd trust Google to do a much better job than I ever could.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Nov 22nd, 2007, 21:34
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Hey thanks guys, i had a bit of a moan on my last post & felt a little ashamed when i re-read it today, i have put myself through stress trying to learn two quickly!

I hope you all accept my appologies, am normally a very placid fella, thank you everyone for your help!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Nov 22nd, 2007, 21:53
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Cheers Ad-wrock for the help but the link is the same one Alex sent me, am abit unsure of what to do with the tutorial found on the link:

Is there a form to go with it Adrock/Alex?

What type of database does it require to use it? I heard that MYISAM database needs to be used when u make use of a search engine is this wrong?

Why couldnt the man who madethe tutorial provide a form & databse for novice learners to go with the code explanation.

I agree with Alex geek about the google search engine, i heardthere is a possible privacy factor involved when using there search engine, besides i only like using what i have created.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #10  
Old Nov 23rd, 2007, 09:03
Most Reputable Member
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Quote:
Originally Posted by longstand View Post
i heardthere is a possible privacy factor involved when using there search engine
To use Google's search engine, you must allow it to index your pages. If for some reason you exclude it or it can't access the page (such as a secure page), then obviously the search won't find the page.

Other than that, Google will be indexing your pages anyway; that's how people find your website! So what's the privacy issue?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #11  
Old Nov 23rd, 2007, 11:28
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Google are a very nosy franchise m8t, but i get your drift, at least you tried to help & repleyed! have you noticed this forum is turning into tit for tat argument zone for smarty pants fighting to be the top geek?

You post a question and get email disturbed in the hope that someone has help for your problem, and it just turns out to be anouher let down of tit 4 tat bithing between other members.. Its not right i say

I used to love this forum when i first joined, infact i learnt load from it, especially from Rakuli,

Dont no whats going on here latley do...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #12  
Old Nov 23rd, 2007, 12:05
Reputable Member
Join Date: Jun 2007
Location: uk
Posts: 459
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

didnt you have any joy with the script I sent you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #13  
Old Nov 23rd, 2007, 12:40
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

Yer i got it working thanks again for that mate, just had problems optimising the results to display a little better!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #14  
Old Nov 23rd, 2007, 16:27
Reputable Member
Join Date: Oct 2007
Location: Liverpool UK
Age: 29
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Search engine links

For anyone needing a php search engine to adapt from with the form, so you can get to grips with how it all works then here it is.

This search engine was built by myself & the very helpfull dab42pat, i hope this helps someone out


Search engine & form below:

PHP: Select all

<?php
mysql_connect
('localhost''root''your password goes here');
if (
mysql_errno()) {
    
trigger_error('Couldn\'t select database - '.mysql_error());
}
mysql_select_db('dbsignup');
if (
mysql_errno()) {
    
trigger_error('Couldn\'t select database - '.mysql_error());
}
$searchSubmitted false;
if (
$_SERVER['REQUEST_METHOD'] == 'POST')
{
    
$searchSubmitted true;
    
    
$criteria = array();
    
    if (!empty(
$_POST['gender'])) {
        
// Gender selected - gender is a string
        
$criteria[] = 'gender = \''.mysql_real_escape_string($_POST['gender']).'\'';
    }
    
    if (!empty(
$_POST['age'])) {
        
// Age selected - age can only be a number
        
$criteria[] = 'age = '.((int) $_POST['age']);
    }
    
    if (!empty(
$_POST['height_one']) && !empty($_POST['height_two'])) {
        
// Both height_one and height_two are selected
        
$criteria[] = 'age BETWEEN '.((int) $_POST['height_one']).' AND '.$_POST['height_two'];
    } else if (!empty(
$_POST['height_one'])) {
        
// Only height_one was selected
        
$criteria[] = 'age >= '.((int) $_POST['height_one']);
    } else if (!empty(
$_POST['height_two'])) {
        
// Only height_two was selected
        
$criteria[] = 'age <= '.((int) $_POST['height_two']);
    }
    
    
$sql 'SELECT * FROM customer';
    
    if (
count($criteria) > 0) {
        
// Only add a where clause if some criteria have been selected.
        // If no criteria are selected, show all results.
        
$sql .= ' WHERE ('.implode(') AND ('$criteria).')';
    }
    
    
// This is for debugging - remove it when you're happy with how things work
    
print '<pre>'.htmlspecialchars($sql).'</pre>';
    
    
$result mysql_query($sql);
    
    if (
mysql_errno()) {
        
trigger_error('Query failed - '.mysql_error(), E_USER_ERROR);
    }
    
    
$customers = array();
    while (
$customer mysql_fetch_assoc($result)) {
        
$customers[] = $customer;
    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <title>Test</title>
    </head>
        <body>
            <form method="post">
                <p>
                    Gender:
                    <select name="gender">
                        <option value="">(either)</option>
                        <option>Male</option>
                        <option>Female</option>
                    </select>
                </p>
                <p>
                    Age:
                    <select name="age">
                        <option value="">(any)</option>
                        <option>18</option>
                        <option>19</option>
                        <option>20</option>
                        <option>21</option>
                        <option>22</option>
                        <option>23</option>
                        <option>24</option>
                        <option>25</option>
                        <option>26</option>
                        <option>27</option>
                        <option>28</option>
                        <option>29</option>
                    </select>
                </p>
                <p>
                    Height:
                    <select name="height_one">
                        <option value="">(any)</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                    </select>
                    to
                    <select name="height_two">
                        <option value="">(any)</option>
                        <option>1</option>
                        <option>2</option>
                        <option>3</option>
                        <option>4</option>
                    </select>
                </p>
                <p>
                    <input type="submit" value="Search" />
                </p>
            </form>
            <?php if ($searchSubmitted): ?>
                <?php if (count($customers) == 0): ?>
                    <p>
                        Sorry, no customers were found for your search. Try altering your search options.
                    </p>
                <?php else: ?>
                    <table>
                        <?php foreach ($customers as $customer): ?>
                            <tr>
                                <td><?php echo htmlspecialchars($customer['first_name']); ?>
                                <td><?php echo htmlspecialchars($customer['age']); ?>
                            </tr>
                        <?php endforeach; ?>
                    </table>
                <?php endif; ?>
            <?php endif; ?>
        </body>
    </head>
</html>

Here is the database i used to:

CREATE DATABASE IF NOT EXISTS dbsignup;
USE dbsignup;
CREATE TABLE `customer` (`customer_id` INT( 3 ) NOT NULL
AUTO_INCREMENT,
`first_name` VARCHAR(30) NOT NULL ,
`last_name` VARCHAR(30) NOT NULL ,
`address` VARCHAR(70) NOT NULL ,
`city` VARCHAR(40) NOT NULL ,
`area` VARCHAR(50) NOT NULL ,
`email` VARCHAR(70) NOT NULL ,
`phone` int(20) NOT NULL ,
`user_name` VARCHAR(30) NOT NULL ,
`password` VARCHAR(30) NOT NULL ,
`work_location` VARCHAR(60) NOT NULL ,
`agency_name` VARCHAR(70) NOT NULL ,
`agency_number` VARCHAR(30) NOT NULL ,
`skills` VARCHAR(500) NOT NULL ,
`about_me` VARCHAR(500) NOT NULL ,
`myspace_address` VARCHAR(50) NOT NULL ,
`hotmail_yahoo_address` VARCHAR(50) NOT NULL ,
`gender` VARCHAR(10) NOT NULL ,
`age` VARCHAR(3) NOT NULL ,
`height_one` int(20) NOT NULL ,
`height_two` int(20) NOT NULL ,
`build` VARCHAR(20) NOT NULL ,
`eye_colour` VARCHAR(20) NOT NULL ,
`hair_colour` VARCHAR(30) NOT NULL ,
`desired_work` VARCHAR(100) NOT NULL ,
`image_one` VARCHAR(10) NOT NULL ,
`image_two` VARCHAR(10) NOT NULL ,
`image_three` VARCHAR(10) NOT NULL ,
`image_four` VARCHAR(10) NOT NULL , UNIQUE ( `customer_id` ) );


Cheers!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #15  
Old Nov 23rd, 2007, 20:36
Highly Reputable Member
Join Date: Apr 2007
Location: Willich, Germany
Age: 20
Posts: 593
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: [SOLVED] Search engine links

Well done, longstand! Sorry if we weren't so helpful at times. But the best way to learn is to do it yourself....

Thanks 4 posting your solution!
Last Blog Entry: