Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Searchable Database

    Hey, I was wondering how do I make a searchable database like this one www.itemdb.biz ?

    What I mean is a search form that would search a spesific place and show you the results.


    Thanks in advance ;D


    Chrisprivate@live.com

    Note: If I get the help I want I can possibly donate some money

  • #2
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for the help if anyone will reply

  • #3
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Like this

    search.php?search=mysearch

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Hi Jelleh,

    There's 5 parts to what you are wanting to do.
    1. Create your database
    2. Create a search form
    3. Receive the data from the form
    4. Perform a search based on the data & display results

    The example you have given is quite a simple search, just looking at the "title" of each Item.

    1: Create a database
    I'm assuming you have access to some basic tools like PHPMYADMIN? You'll need to design your database and input your data accordingly.

    I'd use 1 table, with 2 columns. For our example, we'll call the table "search"
    id, title, (you can add what ever you want here), the example you have given also uses "revision".

    Set your "id" to "Auto-increment". When new data is added to the table, it will then generate the next ID in line by itself. This will also be really useful if you make a little admin interface further down the line to add/edit/delete search results.

    2: Create a search form
    Code:
    <form action="handlingpage.php" method="get">
       <input type="text" name="search" />
       <input type="submit" value="search" />
    </form>
    Using "method=get" puts the search term in the URL of the handling page. Be warned though, this provides a perfect opportunity for your site to be hacked. There are various checks you'll need to learn about to ensure that the search term provided is suitable for passing through your database.

    3: Receive the data from the form
    You'll need a handling page to get the data from the form and work with it.

    PHP Code:
    // Get user input.
    $search mysql_escape_string(strip_tags($_GET['search'])); 
    Perform a search based on the data & display results
    Once you've got your data, you can search your database with it.

    PHP Code:
    // Query
    $q mysql_query("SELECT * FROM `search` WHERE `title`='" $search "'") or die(mysql_error());
    // Get results from Query
    while($r mysql_fetch_array($q)) {
     echo 
    $r['id'] . ' - ' $r['title']; // Display our ID and Title

    In the example above, we create a WHILE loop. This tells the page to display results from the database until there is nothing else to display.

    I'm assuming you have some knowledge of HTML/PHP. If you need any help, just ask.

  • Users who have thanked patch for this post:

    Jelleh (01-29-2012)

  • #5
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by patch View Post
    Hi Jelleh,

    There's 5 parts to what you are wanting to do.
    1. Create your database
    2. Create a search form
    3. Receive the data from the form
    4. Perform a search based on the data & display results

    The example you have given is quite a simple search, just looking at the "title" of each Item.

    1: Create a database
    I'm assuming you have access to some basic tools like PHPMYADMIN? You'll need to design your database and input your data accordingly.

    I'd use 1 table, with 2 columns. For our example, we'll call the table "search"
    id, title, (you can add what ever you want here), the example you have given also uses "revision".

    Set your "id" to "Auto-increment". When new data is added to the table, it will then generate the next ID in line by itself. This will also be really useful if you make a little admin interface further down the line to add/edit/delete search results.

    2: Create a search form
    Code:
    <form action="handlingpage.php" method="get">
       <input type="text" name="search" />
       <input type="submit" value="search" />
    </form>
    Using "method=get" puts the search term in the URL of the handling page. Be warned though, this provides a perfect opportunity for your site to be hacked. There are various checks you'll need to learn about to ensure that the search term provided is suitable for passing through your database.

    3: Receive the data from the form
    You'll need a handling page to get the data from the form and work with it.

    PHP Code:
    // Get user input.
    $search mysql_escape_string(strip_tags($_GET['search'])); 
    Perform a search based on the data & display results
    Once you've got your data, you can search your database with it.

    PHP Code:
    // Query
    $q mysql_query("SELECT * FROM `search` WHERE `title`='" $search "'") or die(mysql_error());
    // Get results from Query
    while($r mysql_fetch_array($q)) {
     echo 
    $r['id'] . ' - ' $r['title']; // Display our ID and Title

    In the example above, we create a WHILE loop. This tells the page to display results from the database until there is nothing else to display.

    I'm assuming you have some knowledge of HTML/PHP. If you need any help, just ask.
    Thanks!

    So for the handlingpage.php I just paste this in it?
    Code:
    // Get user input.
    $search = mysql_escape_string(strip_tags($_GET['search']));
    Could rar all the files please?

    Thanks a lot!

  • #6
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    Quote Originally Posted by Jelleh View Post
    Could rar all the files please?

    Thanks a lot!


    sorry, that made me smile..

  • #7
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jmj001 View Post


    sorry, that made me smile..
    Read my usertitle

    New to the CF scene


  • #8
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    patch has given you an extremely detailed answer to your question...

    if you follow his steps you will be able to do what you asked for help for...

    i think, and it's just my opinion, that you shouldn't expect him to write the scripts for you and send them to you in compressed format...

    he and many others here will help you with advice for specific problems but you need to put in the effort yourself and do the work...

    again, it's just my opinion... not necessarily the opinion of the masses and i probably shouldn't have made comment... my apologies if i offended

  • Users who have thanked jmj001 for this post:

    Jelleh (01-29-2012)

  • #9
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jmj001 View Post
    patch has given you an extremely detailed answer to your question...

    if you follow his steps you will be able to do what you asked for help for...

    i think, and it's just my opinion, that you shouldn't expect him to write the scripts for you and send them to you in compressed format...

    he and many others here will help you with advice for specific problems but you need to put in the effort yourself and do the work...

    again, it's just my opinion... not necessarily the opinion of the masses and i probably shouldn't have made comment... my apologies if i offended

    You got msn or something?

    chrisprivate@live.com

    If you don't

    www.tinychat.com/cfdatabase

  • #10
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    sorry mate, not looking for friends at the moment

  • #11
    New Coder
    Join Date
    Oct 2011
    Posts
    16
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jmj001 View Post
    sorry mate, not looking for friends at the moment

    You seem like you know what you are talking about.

    Tinychat is just a chatroom.

    Could you be arsed to help?

    Thanks


  •  

    Posting Permissions

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