...

View Full Version : Searchable Database



Jelleh
01-28-2012, 04:05 PM
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 :D

Jelleh
01-28-2012, 04:14 PM
Thanks for the help if anyone will reply :D

Jelleh
01-28-2012, 04:18 PM
Like this

search.php?search=mysearch

patch
01-28-2012, 05:26 PM
Hi Jelleh,

There's 5 parts to what you are wanting to do.

Create your database
Create a search form
Receive the data from the form
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


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



// 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.



// 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. :)

Jelleh
01-29-2012, 10:39 AM
Hi Jelleh,

There's 5 parts to what you are wanting to do.

Create your database
Create a search form
Receive the data from the form
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


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



// 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.



// 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?


// Get user input.
$search = mysql_escape_string(strip_tags($_GET['search']));

Could rar all the files please?

Thanks a lot!

jmj001
01-29-2012, 10:48 AM
Could rar all the files please?

Thanks a lot!

:p

sorry, that made me smile..

Jelleh
01-29-2012, 11:00 AM
:p

sorry, that made me smile..

Read my usertitle

New to the CF scene

:(

jmj001
01-29-2012, 11:08 AM
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 :o

Jelleh
01-29-2012, 11:10 AM
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 :o


You got msn or something?

chrisprivate@live.com

If you don't

www.tinychat.com/cfdatabase

jmj001
01-29-2012, 11:12 AM
sorry mate, not looking for friends at the moment

Jelleh
01-29-2012, 11:13 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum