Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 30
  1. #1
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hello,
    Anyone can help me please?
    I would like to implement on my web site a search box which will look for pictures. Exactly the same as google image search (only tiny, small one). Simple search box, no other search options. In google when I input a name ex. “apple” and click Search dozens of pictures are displayed on few pages. I would like to do the same. But how? Is there any programme I could buy, or maybe all I need is just a script? Where do I need to put all my pictures to be searched through?

  2.  

  3. #2
    Senior Member
    Join Date
    Apr 2005
    Location
    Hatfield, England
    Posts
    855
    Member #
    9790
    Look at the Google website, they have a script which you can install. The script will index your site then make it all searchable.

  4. #3
    Senior Member Shani's Avatar
    Join Date
    Nov 2004
    Posts
    1,140
    Member #
    8171
    If you want to DIY, make one of the requirements a file extension that matches all the options for images your site supports.
    Shani

    I have an eye for detail like you'd never believe.

  5. #4
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Hi guys,
    thanks for reply. i'm still not that good to understand all that. i was looking in google search for a google script, but didn't find any. i would like to do DIY, but how and where to start?

    could you maybe tell me where to find easy, step by step explanation?
    thank you very much
    pierrot

  6. #5
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Ideally, you will want to store the images paths in a database, and keep the images in a specified directory.

    Then, depending on your preference, the user searches against either the filename (so you would have to have images with meaningful names, in your example of apples, a meaningful name would be green-bramley-apple.gif) or they could search against a description which you set when you add new images, which in my example would be A image of a green bramley apple.

    So you would run your search, and try to extract any rows that meet the user's query, if 1 or more are returned you would get the filename value from each row and use that to write out a <img> tag.

    Not sure if your hot on PHP interacting with databases and the like, if you need help with the code just ask, however having a understanding of this would be an idea.

  7. #6
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Thank you for message Bfsog.
    I’m not that good in PHP, but I know how to build a database and if you could point to the script I would definitely like to try. Searches against the filename sounds good, I’d like to do this way, any tutorials you could point please? I was checking google, but I even don't know how to call this option in professional way: every search is ending up with companies offerening search option using their services.
    Speaking about PHP, maybe you could recommend me a good book to learn everything about? I could order on amazon, or ebay. I got from ebay a DVD tutorial, but is it not that fantastic.

    Thank you very much.

  8. #7
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey. I wrote a quick script for you.

    PHP Code:
    <html>
    <head>

        <title>Search for Image</title>

    </head>
    <body>

    <?php

    // Check if the user has searched or not

    if($_GET['btn'] == "Search")
     {
        
    // Begin Connection
        
    include("conn.php");
        
    $q $_GET['q'];
        
    $query "SELECT * FROM imgs WHERE img_filename LIKE '%$q%'";
        
    $result mysql_query($query) or die(mysql_error());
        while(
    $row mysql_fetch_array($result))
         {
            echo 
    $row['img_filename'];
         }

     } else
     { 
    ?>

    <form name="search" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">

    Search For: <input type="text" name="q" value="" />

    <br />

    <input type="submit" name="btn" value="Search" />

    </form>

    <?php

    }

    ?>

    </body>
    </html>
    In the table imgs I inserted a test row, I put the filename as 'apple la.jpg"

    So, if I search for app or le or la (and so on) that row will be returned, as I use the LIKE command with a starting and ending % which means if this string appears anywhere in the columns value.

    The fields in my table were img_id (int auto inc primary), img_filename (varchar 30), img_width (int size 4) img_height (int size 3).

    I had the width and height column as if you added new images via a webpage you would want to record the width and height.

  9. #8
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Thank you so much for your help.
    I guess this is only the first part, the part I have to implement on my web.
    What o I have to do with database for it to work?
    How do I organise “table imgs” and where do I place it?
    Also, how do I connect the created database with this script? Where do I enter database name, password, username?

  10. #9
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    You will need to create the table first of all on a database.

    Query:
    Code:
    CREATE TABLE `imgs` (
    `img_id` INT( 4 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
    `img_filename` VARCHAR( 50 ) NOT NULL ,
    `img_width` INT( 4 ) NOT NULL ,
    `img_height` INT( 4 ) NOT NULL
    ) ENGINE = MYISAM ;
    If you run that through phpMyAdmin, or indeed via a PHP page, that should create your table.

    And to connect to the database, I stored that code in the conn.php file

    Code:
    PHP Code:
    <?php

    // change the values to match your database

        
    $location "localhost";
        
    $username "";
        
    $password "";
        
    $database "";
        
    $conn mysql_connect("$location","$username","$password");

        
    mysql_select_db($database,$conn) or die ("Could not open database");

    ?>

  11. #10
    Member
    Join Date
    Sep 2006
    Posts
    77
    Member #
    14004
    Bfsog,
    To summarise what we did until now:
    * We have the script to implement on the “Search For Images” page (images.html)
    * I created a database (host_picsdata) and a table with four fields and specifications as above.

    How do i set up all names of images to be displayed when someone is entering “apple” in my search box? Do i enter some information in “Search” option in phpMyAdmin?
    Do i have a say about the results’ display: I would like to direct the results to a new page, on the bottom left?
    Where do I need to upload the second php script (//change the values to match your database... ), in the same folder with all my images? Same folder with “images.html”?

    Thank you very much for helping


Page 1 of 3 1 2 3 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:04 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com