# Help! Searchable database for my website. Important!



## kristenkeys (Dec 4, 2006)

Hi all.

I'm working on my company's website, and my biggest issue is that I can't figure out how to make a searchable database (or find a good program to make one for me). This is the search page now, but it does not work: http://www.dwigmore.com/db/wigmore_search.html

They want to still keep these fields (artist, time period, etc) but I just simply cannot figure out how to do this. If someone can help me and walk me through the process (or just send me a tutorial), or reccomend a good databse program which I could buy, I'd be very grateful.

Thank you for all of your help,

Kristen


----------



## NewDesigner (May 1, 2007)

http://www.scriptlance.com/

http://www.rentacoder.com/


----------



## harmor (Mar 15, 2007)

It would be easy if you stored all your data in a database but you didn't but you can use Snoopy or cURL to search.


----------



## kristenkeys (Dec 4, 2006)

harmor-- that's what i am saying. i want to store everything in a database, but i need a program that can also encode it for me to put on my website because i don't know how to do all of that.

new designer-- thanks.. i'm going to check out those two today.


----------



## harmor (Mar 15, 2007)

Create new database. In the database create a table named "paintings". Add these columns to the newly created tables


pid
artist
medium
era
category
style
school
art colony
area_collecting

There's more but I'll wait until you're done.


----------



## kristenkeys (Dec 4, 2006)

I really appreciate this. OK done with that part.


----------



## harmor (Mar 15, 2007)

Now you'll need to insert the data into the table. Do you know how to do that?


----------



## kristenkeys (Dec 4, 2006)

Is there an easier way than just typing each painting's info in? I may have to do it that way anyway, because my most current listing of all the paintings isn't updated. It's not a big deal-- our website doesn't list our total inventory, so I'm only working with about 200 entries here.

What do you do after that?


----------



## harmor (Mar 15, 2007)

On this page you'll need to change a few things. First you'll need to rename it "index.php".

You'll need to connect to the databse and loop through

```
[TR]
[TD][URL=javascript:openWin('01.html');][IMG alt=""]img/jenkins_estuary_th.jpg[/IMG][/URL][/TD]
[TD][URL=javascript:openWin('02.html');][IMG alt=""]img/jenkins_ultrared_th.jpg[/IMG][/URL][/TD]
[/TR]
```


```
$getpaintings = mysql_query("SELECT * FROM `paintings` WHERE online_exh = '0' ");
while($paint = mysql_fetch_array($getpaintings))
{
  echo "[TR]
[TD][URL][IMG alt=""]img/".$paint[[/IMG][/URL][/TD]
[TD][URL][IMG alt=""]img/".$paint[[/IMG][/URL][/TD]
[/TR]";
}
```


----------



## harmor (Mar 15, 2007)

I forgot to mention you'll need to create a new column on the table.
After "area_collecting" add "online_exh" and make it a tinyint.


----------



## kristenkeys (Dec 4, 2006)

Ok, I haven't added each painting's info yet (still working on that as we speak), but I'm not sure what you mean by "connect to the database and loop through"  sorry, I can't believe how far behind I've fallen on learning this stuff...

Once I'm done with enterting my database's info, I will rename my page to .php instead of .html, and then I will replace the html code with php. Be back...


----------



## harmor (Mar 15, 2007)

This is how to connect to the database.

Create a file named "db.php" and add the following.

```
<?php
mysql_connect("localhost", "_username_", "_password_") or die(mysql_error());
echo "Connected to MySQL
";
mysql_select_db("_database_") or die(mysql_error());
echo "Connected to Database";
?>
```
Change "_username_", "_password_", and, "_database_".
I added the underscores to make it easier to find for you. Don't delete any of the quotations.

In "index.php" add this at the top

```
<?php
require("db.php");
?>
```


----------



## tjamnz (Jun 15, 2004)

thanks for the script harmor... 

but just how secure is it? Should it be safe from injection?

thanks.


----------



## kristenkeys (Dec 4, 2006)

I've done all of this so far, but my server just went down! My ftp won't connect and I can't upload anything. I am going to take this opportunity to keep plugging my info into the database. But I'm still keeping up with you.


----------



## harmor (Mar 15, 2007)

tjamnz said:


> thanks for the script harmor...
> 
> but just how secure is it? Should it be safe from injection?
> 
> thanks.


So far there is no way to execute SQL injections into the query.


----------



## harmor (Mar 15, 2007)

kristenkeys said:


> I've done all of this so far, but my server just went down! My ftp won't connect and I can't upload anything. I am going to take this opportunity to keep plugging my info into the database. But I'm still keeping up with you.


Did you make "pid" an "INT", auto_increment, and the primary key?


----------



## kristenkeys (Dec 4, 2006)

no  I don't know how... I can't find it anywhere in my program or anything on how to do it in my help menu.

I am in so far over my head and I am stressing out! Not only does this need to be done, but I want to learn how to do it. But I just don't know annnny of this stuff.


----------



## kristenkeys (Dec 4, 2006)

OK I actually figured it out. So i am current, and I made "pid" the key, etc.


----------



## harmor (Mar 15, 2007)

Did you do this yet...

After "area_collecting" add "online_exh" and make it a tinyint.


----------



## tjamnz (Jun 15, 2004)

muy excellente!!!!

fantastico is pretty cool... i created a subdomain....photos._mywebsitename._com and installed "gallery" (a specialized photo blog)... it created the mysql database automatically.. just like most of the other apps do to.


----------



## kristenkeys (Dec 4, 2006)

harmor said:


> Did you do this yet...
> 
> After "area_collecting" add "online_exh" and make it a tinyint.


yeah, i did this too. woo!


----------



## kristenkeys (Dec 4, 2006)

harmor, i'm going home now. i'll be back tomorrow and if you can help i'd love it. otherwise, i should be able to get some work done on my own. i can see the progress being made and know that i am on the right track.

thank you,kristen


----------



## harmor (Mar 15, 2007)

I probably be on tomorrow to help more. If you trust me I can work on the files myself because it's difficult to explain what to do when I can't see what is going on.


----------



## harmor (Mar 15, 2007)

harmor said:


> On this page you'll need to change a few things. First you'll need to rename it "index.php".
> 
> You'll need to connect to the databse and loop through
> 
> ...


Sorry I forgot to change something on the code above.


```
$getpaintings = mysql_query("SELECT * FROM `paintings` WHERE online_exh = '0' ");
while($paint = mysql_fetch_array($getpaintings))
{
  echo "[TR]
[TD][URL][IMG alt=""]img/".$paint[[/IMG][/URL][/TD]
[TD][URL][IMG alt=""]img/".$paint[[/IMG][/URL][/TD]
[/TR]";
}
```
You'll need to add two more columns to the table.
Add "width" and "height" and make them "smallint" with a value of 3


----------

