SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A search tutorial

    Hi Guys,

    I'm looking for a search tutorial to help me understand how I could explore the possibility of building a search page with fields, such as:

    http://jobsearch.monster.co.uk/
    http://www.fish4.co.uk/iad/jobs/advanced
    http://www.primelocation.com/uk-property-for-sale/

    Could anyone point me in the direction of any URLS?

    Many Thanks

  2. #2
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If the data is kept in a datbase, and that database is mysql; this site links to many tutorials dealing with search and look for fulltext in particular.

    http://www.justphukit.com/mysql/mysql-tutorials-1.php

    I hope that is what you were looking for...
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  3. #3
    Non-Member
    Join Date
    Feb 2005
    Posts
    737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

    But i'm looking for a tutorial that deals more with conditions.

    ie: If I wanted a house that was a 'semi-detached' + 'in london' + 'had a garage'

    How would I query the database to search for these conditions and output the results from the database back to my live site?

    See what I mean?

    Many Thanks

    Chris

  4. #4
    SitePoint Wizard Nikolas's Avatar
    Join Date
    Feb 2005
    Location
    Greece
    Posts
    1,221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is a very good one regarding the full text queries in mysql :

    http://www.phpfreaks.com/tutorials/129/0.php

  5. #5
    SitePoint Wizard bronze trophy bigalreturns's Avatar
    Join Date
    Mar 2006
    Location
    The Wirral, England
    Posts
    1,293
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7724
    Thanks,

    But i'm looking for a tutorial that deals more with conditions.

    ie: If I wanted a house that was a 'semi-detached' + 'in london' + 'had a garage'

    How would I query the database to search for these conditions and output the results from the database back to my live site?

    See what I mean?

    Many Thanks

    Chris
    It would depend on how you had the information stored in your database, but say you stored it something like...
    Type (1=Terrace,2=Semi,3=Detached)
    Garage (1=Yes,0=No)
    Location

    then you could query with

    SELECT * FROM houses WHERE type='2' AND garage='1' AND location='london'

    then go through the rows using

    WHILE ($row=mysql_fetch_row($result) {
    echo (data from this house);
    }

    Hope thats some help,

    Alex
    "The proper function of man is to live - not to exist."
    Get a Free TomTom


  6. #6
    is_empty(2); foofoonet's Avatar
    Join Date
    Mar 2006
    Posts
    1,000
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But i'm looking for a tutorial that deals more with conditions.
    That basically means learning more about sql. The sql forum would be a good place to ask questions when you have specific questions. The stuff they come out with is amazing.

    Fulltext is a special index that automatically does a lot of the stuff you might describe as "fuzzy" or intelligent... strips out noise words, looks for proximity of words and ranks the results for you.

    fulltext provides a clever solution if you have a text field(s) that contain lots of words, eg room descriptions.
    Upgrading to Mysql 5? Auto-increment fields now strict
    use NULL
    Or zero or leave the field name out completely.

  7. #7
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This Should Help: This is One of my Search Page code, I got this code from Sitepoint Helper & it worked out great for me.

    PHP Code:
    <TITLE>ADMIN (RECORD SEARCH)</TITLE>

    <?PHP
    // GET DATA FROM VPT_ADMIN OR SELF_SUBMISSION & ASSIGN IT TO NEW VARIABLES
    if ( (isset($_GET['PartList'])) && (isset($_GET['vpt_dbname'])) && (isset($_GET['img_dir'])) )
        { 
    $vpt_table_partlist=$_GET['PartList']; $vpt_dbname=$_GET['vpt_dbname']; $img_dir=$_GET['img_dir']; }
    else
        { 
    $vpt_table_partlist=$_POST['PartList']; $vpt_dbname=$_POST['vpt_dbname']; $img_dir=$_POST['img_dir']; }

    include 
    'library/config.php';
    include 
    'library/opendb.php';
        
    $query="SELECT * FROM `$vpt_table_partlist` ORDER BY partlist_id DESC";
        
    $mysql_result mysql_query ($query) or die (mysql_error());
    include 
    'library/closedb.php';
    ?>

    <BODY BGCOLOR=#999999>
        <!-- DISPLAY SEARCH FORM -->    
        <FORM Action="<?PHP echo $_SERVER['PHP_SELF']?>" Method="POST">
        <TABLE width=700 border=1 cellpadding=2 cellspacing=2 align=center BGCOLOR=#CCCCCC>
            <input type="hidden" name="PartList" value="<?PHP echo $vpt_table_partlist?>">    
            <input type="hidden" name="vpt_dbname" value="<?PHP echo $vpt_dbname?>">
            <input type="hidden" name="img_dir" value="<?PHP echo $img_dir?>">    
            
            <TR><TD align=center>
                <H2>VISUAL PRODUCT TREE</H2><B>--- RECORD SEARCH ---</B>
            </TD></TR>
            <TR><TD align=center>
                Part No:<input type="text" name="search_part" value="" size=15> 
                Part Desc:<input type="text" name="search_desc" value="" size=20>
                Reports To:<select name="search_reportsto">
                    <option value=""> </option>
                    <option value="Knob Rotator Subassy">Knob Rotator Subassy</option>
                    <option value="Housing Subassy">Housing Subassy</option>
                    <option value="PCB Bracket Subassy">PCB Bracket Subassy</option>
                    <option value="Contact Switch Assembly">Contact Switch Assembly</option>
                    <option value="Union Ball Valve Assembly">Union Ball Valve Assembly</option>
                </select>
                <input type="submit" name="Submit" value="GO"><br>
            </TD></TR>
        </TABLE>        
        </FORM>
    </BODY>
            
    <?PHP
    if (isset($_POST['Submit']))
    {
        
    $vpt_table_partlist=$_POST['PartList'];        $search_part=$_POST['search_part'];
        
    $search_desc=$_POST['search_desc'];            $search_reportsto=$_POST['search_reportsto'];

        include 
    'library/config.php';
        include 
    'library/opendb.php';
            
    $wh = array();
            if (
    strlen($search_part))            // check for query by search_part field
                
    {  $wh[] = '(part_no LIKE \'%' $search_part '%\')';    }
            if (
    strlen($search_desc))            // check for query by search_desc field
                
    {  $wh[] = '(part_desc LIKE \'%' $search_desc '%\')';    }
            if (
    strlen($search_reportsto))        // check for query by search_reportsto field
                
    {  $wh[] = '(part_reportsto = \'' $search_reportsto '\')';    }
            
            
    $sql "SELECT * FROM `$vpt_table_partlist` WHERE ";
            
    $sql .= implode(" AND "$wh);    // $sql now has the correct SQL statement to query the database 
                
    $query=$sql;
                
    $mysql_result mysql_query ($query) or die (mysql_error()); 
        include 
    'library/closedb.php';
    }
        while (
    $row mysql_fetch_object ($mysql_result)) 
        {
    ?>

        <TITLE>ADMIN (RECORD SEARCH)</TITLE>
        <BODY BGCOLOR=#999999>
            <!-- DISPLAY ALL RECORDS OR SEARCH CRITERIA RECORDS -->
            <TABLE width=700 border=1 cellpadding=2 cellspacing=2 align=center BGCOLOR=#CCCCCC>
                <TR><TD width=150 align=right><b>Part No:</b></TD>
                    <TD width=250 align=left><?PHP echo $row->part_no " > " $row->part_desc ?></TD>
                    <TD width=150 rowspan="5" align=center valign=center>
                        <img src="../Project/<?PHP echo $img_dir ?>/<?PHP echo $row->gif_image ?>">
                    </TD>
                </TR>
                
                <TR><TD width=150 align=right><b>Reports To:</b></TD>
                    <TD width=250 align=left><?PHP echo $row->part_reportsto ?></TD>
                </TR>
                <TR><TD width=150 align=right><b>Assembly:</b></TD>
                    <TD width=250 align=left><?PHP echo $row->part_assy ?></TD>
                </TR>        
                <TR><TD width=150 align=right><b>Attachments:</b></TD>
                    <TD width=250 align=left><?PHP echo $row->attach_pdf " - " $row->attach_3d ?></TD>
                </TR>
                <TR><TD width=150 align=right><b>Comments:</b></TD>
                    <TD width=250 align=left>
                        <a href="v4vpt_bom_admin.php?PartList=<?PHP echo $vpt_table_partlist?>
                            &vpt_dbname=<?PHP echo $vpt_dbname?>&img_dir=<?PHP echo $img_dir?>">
                            Record Administration</a></TD>
                </TR>
                <TR><TD align=center colspan=3><B>--- --------------- ---</B></TD></TR>        
            </TABLE><BR>
        </BODY>

    <?PHP
        
    }
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •