If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Beginner looking for advice on creating a multi variable web search function.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-11-08, 15:13
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
Beginner looking for advice on creating a multi variable web search function.

Greetings

I am trying to get a search able database for my site I hope I am posting this in the right place, if not please feel free to more or delete it and I'll know that I was wrong. Well this is my project I have been trying deferent search engines from here for my Tarantula website and I haven't really come up with anything pre made for the search function it just needs to allow users search by all or any of these options.

1. Scientific Names = genus + species-----------------Will be added over time
2. Genus = 100+ different tarantulas------------------Can be added upfront but may need to change or add to over time
3. Species = 800+ different species-------------------Will be added over time
4. color = The most common colors---------------------Will be added over time
5. Gender = Male, Female------------------------------Fixed
6. Humidity = Low 50% to 60%, Medium 60% to 70%, High 70% to 85%-----------Fixed
7. Speed = Slow, Medium, Fast-------------------------Fixed
8. Temperature = Cool 50°F to 80°F, Warm 60°F to 90°F, Hot 75°F to 90°F----Fixed
9. Max Size = 1" to 3", 4" to 6", 7" to 8, 9"+--------Fixed
10. Location = New World, Old World-------------------Fixed
11. Housing = Arboreal, Terrestrial, Fossorial--------Fixed

There are 800+ different types of Tarantulas and 99% of the time, you decided you want a big one or a small one or a blue one or a extra harry one before you find out what Tarantulas actually have those traits. I would like my site to be a place where you can search for blue and find all the Tarantulas that are tagged as blue. You could mix and match and search to find all the blue Tarantulas that are Old World and so on.

I also need a system that will allow users to submit Tarantulas to my website using their scientific names along with any other information or pictures they have. There also must be a way for me/admin to approve/deny/edit all the submission before they are posted into the site or made search able. So there will need to be some type of admin login panel that will allow me/admin to be the only ones able to approve/deny/edit the submission.

There must also be some way to upload images and data about the Tarantulas that are already existing in the site. I also need to be able to have a good looking results page.


Well you've got to start some where right? Grin Please forgive me for the following vague questions but being a beginner its really be a challenge to explain everything I need the search function to do.

I would really appreciate it if you guys would be so kind as to help me figure out what sets of code/database or program will allow me to accomplish this?

My most important question is how a beginner should go about starting a project like this?

I was advised to check out regex, php, mysql, and ASP (I think it only works on windows server and mine is on a Linux) Huh

This is a link to my site. The only thing I care to keep is the design the form's not connected to anything and for all I know I'll never need them but I made them just to give myself an idea of what I thought it would look like.

http://www.tarantuladatabase.com/ass...es/search.html

Thank you all so much for trying to get me started on the right path.
Reply With Quote
  #2 (permalink)  
Old 06-11-08, 16:57
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Dear Snot

The first thing you want to do is break down your whole project into parts i.e.
  • Getting a web space where you can run mysql and php.
  • Getting a book on the above where you can try out a few examples.
  • Design a database to hold the above data - it could just be a tarantula table and a few lookup tables.
  • Write some code to insert a new spider.
  • Write some code to display an existing spider
  • Write some code to search for a spider.
  • Perhaps how to load in pictures for a spider
  • how to browse from one spider to the next
  • spider of the day photos
It's not a difficult project at all but you'll just have to learn a few things. The searching part can just be as simple as reading a string from the form and then searching each field in your spider table to see if it matches ie

Code:
select name
from Spiders
where name like concat( '%', v_search_str, '%' )
        or scientific_names like concat( '%', v_search_str, '%' )
        or genus like concat( '%', v_search_str, '%' )
        or location like concat( '%', v_search_str, '%' )
        or housing like concat( '%', v_search_str, '%' )
but even here you'll have to be careful of users entering multiple words to search for i.e. "blue aboreal". You're database will probably set up to ignore upper and lower case differences. Performance isn't an issue with only a 1000 items.

Your web page looks like a fine start - at least it looks like you have the html side of things covered.

Mike
Reply With Quote
  #3 (permalink)  
Old 06-11-08, 20:42
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
Thanks so much for helping me!

http://www.tarantuladatabase.com/assets/pages/test.html

This is kinda what I have been playing around with for php If this is working I can see how it works a little.

I haven't been able to get connected to the database I did find out that to make a table I go into my cpanel then into phpmyadmin. I made a table with 1 field but I don't understand what format I need to use.

Will i have 1 table for each spider or will i have 1 table called Tarantula with 1 field called Housing and so one like this.

Code:
Table called Tarantula

>Housing
>>>>>>>>Arboreal
>>>>>>>>Terrestrial
>>>>>>>>Fossorial
>Location
>>>>>>>>New World
>>>>>>>>Old World
>Speed
>>>>>>>>Slow
>>>>>>>>Medium
>>>>>>>>Fast
Is this right at all?
I am confused about the things that I dont know like genes species and color.
Reply With Quote
  #4 (permalink)  
Old 06-11-08, 22:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
don't call your table `database` because DATABASE is a reserved word

call it spiders or species or something meaningful

do you understand the CREATE TABLE statement and how to run it in phpmyadmin?

you will have columns called housing, location, speed

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 06-11-08, 23:03
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
That went right over my head
Reply With Quote
  #6 (permalink)  
Old 06-12-08, 03:27
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
Quote:
Originally Posted by Snot
That went right over my head
OK to make it simple
some words have a specific meaning in MySQL (each database type) has their own little list of words you must not use for table, column, index or other uses. If you attempt to ue one of those words there will be problems.

Database is one of them

for a full list consult the manual for the MySQL version you are using.
V5.0
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #7 (permalink)  
Old 06-12-08, 04:09
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
To create a table you could have:
Code:
create table Spiders (
             spider_type        varchar(100),
             housing              varchar(30),
             location              varchar(30),
             speed              varchar(30)
)
Things to think about:
  • As Rudy mentioned it's better to make the table name a bit more generic so you could store other types of spider in there at some point in the future. I called it Spiders.
  • You have a field called speed (fast,medium,slow) but you might find that people who add data for their spider have no idea how to judge this - ie 5mph fast?
  • Out of curiosity what does Fossorial mean? do they live on skeletons?
  • You could spend a lot of time working out the best size for fields but I didn't really bother. It doesn't waste any more space and I doubt it will be important in this app.
  • You can add lookups later ie a choice of fast medium slow for speed.
  • You might want to have common names as well as scientific names.
  • I assume the unique identifier for these would be name i.e.e how do you identify uniquely one spider from another.

Then you can add a few spiders like this in phpmyadmin:
Code:
insert Spiders ( spider_type,housing,location,speed ) values ( 'The big blue', 'Arboreal', 'New World', 'Fast' )
Then you can see what spiders you've added in phpmyadmin:
Code:
select * from Spiders
You could expand the table so it has all the fields you want and alter the insert statement accordingly. That will then be version 0.1 of your database.

Next would be getting a your web page to insert a spider using a html form to pass all the details to your php program that will do the insert for you. I'd suggest getting a simple book on php and mysql and then following the examples.

Mike
Reply With Quote
  #8 (permalink)  
Old 06-12-08, 09:43
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
Thanks so much for the advice!! i''l let ya know how it goes.

http://en.wikipedia.org/wiki/Fossorial

In the hobby there are three types of tarantulas

Arboreal T's need to be off the ground to hide, in the wild they live in trees.

Terrestrial T's kinda do their own thing but they like to stay on the ground they may dig a small hide or web up the side of the tank but they don't go very far up or down.

Fossorial T's also known as pethole's in the hobby is when you buy a tarantula then it digs a really deep hole and you never see it again
Reply With Quote
  #9 (permalink)  
Old 06-12-08, 09:58
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Must admit I quite like spiders myself – my eldest son and I were at a tiny “zoo” on the south coast of England admiring a very handsome looking Tarantula in one of the cases. As luck would have it, one of the keepers came by to answer a few questions. I eventually asked her if I could hold him - I’d heard as long as you don’t frighten it then it shouldn’t bite and, even if it did, the effects were much exaggerated. The lady looked at me as if I was mad and explained that all the keepers there were absolutely terrified of the thing. Would they harm a fully grown adult or would it be more like a sting from a hornet?
Reply With Quote
  #10 (permalink)  
Old 06-12-08, 10:33
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
Thats a big question hehe.

Some tarantulas you can safely hold others are not recommended to be held by anyone that doesn't want to be bitten.

The two types of T's are split by there location New World (north and south america) and Old World (everywhere else) A good rule of thumb is NW T's have much less potent venom kinda like a wasp sting.

The OW T's on the other hand tend to be much more aggressive and have more potent venom. No one on record has ever died from a T bite but I have heard some crazy stores.

The thing about T's its best not to try and hold a random one until you study up on it. T's look the same for the most part so you cant really tell if the T is like a cuddly dog wagging it's tail or a growling pit bull until you stick your hand in its cage and thats not a good way to find out

Its a really fun hobby if you want to talk to some people about it check out this link www.arachnoboards.com they have a very active forum and a chat room you can ask all kinds of questions.
Reply With Quote
  #11 (permalink)  
Old 06-12-08, 10:35
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
SQL query:

CREATE TABLE `e0120590_tarantuladatabase`.`tarantula` (
`id` VARCHAR( 10 ) NOT NULL AUTO_INCREMENT ,
`housing` VARCHAR( 10 ) NOT NULL ,
`humidity` VARCHAR( 10 ) NOT NULL ,
`speed` VARCHAR( 10 ) NOT NULL ,
`size` VARCHAR( 10 ) NOT NULL ,
`location` VARCHAR( 10 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM

MySQL said: Documentation
#1063 - Incorrect column specifier for column 'id'


How do I change the colum specifier?
Reply With Quote
  #12 (permalink)  
Old 06-12-08, 10:49
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
change
`id` VARCHAR( 10 ) NOT NULL AUTO_INCREMENT
to
`id` VARCHAR( 10 ) varchar NOT NULL
The AUTO_INCREMENT is only used with numeric fields.
You also don't need the single quotes around the field names but that doesn't matter either way.
Reply With Quote
  #13 (permalink)  
Old 06-12-08, 11:25
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
its an ID column, Id expect it to be a numeric column
so id expect something like
`id` integer NOT NULL AUTO_INCREMENT
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #14 (permalink)  
Old 06-12-08, 11:30
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
True but then our spiders are left without names. I just figured Snot had decided that the name was the id and then copied code that had an auto incrementing id field. Perhaps he might want an id and a name field but that seems slightly complex for a first shot.
Reply With Quote
  #15 (permalink)  
Old 06-12-08, 12:00
Snot Snot is offline
Registered User
 
Join Date: Jun 2008
Posts: 14
I think i got the hang of how to create the table... I think

This is my table

http://www.tarantuladatabase.com/table.JPG

and these are the values

http://www.tarantuladatabase.com/value.JPG

I couldn't figure out how to leave a field value black so I just put None in as a place holder.

How does that look?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On