Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old August 2nd, 2001, 08:24 AM
carl_se carl_se is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Sweden
Posts: 2 carl_se User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP and MySQL question

Hello

I would appreciate some help here....

I have a MySQL database with the name "countries" which consists
of a number of tables where each table has the name of a country,
like "Belgium", "Germany", etc. Not all tables are completed, and I
will continue to add more tables. Each table contains 7 fields (we can
call the fields "field1" to "field7"). There's no need for a unique
key, and several of the fields contains rendundant data (as they have
been imported from a texfile, and the storage is not a problem).

From a HTML + PHP page I want to choose country from a pull down
menu like "select - option value" in HTML. Then when the country has
been choosen I want to search for a name in field1, after which all
matches should be printed out on the screen including the content of
field2 to field7 in a row.

I have gone through many examples of PHP and MySQL, but they are
either to basic and simple, or to advanced and complicated. And I believe
that what I want to do is possible to do in PHP, because I know that
I can do it with Perl and a text-based database, but now want to learn
to work with MySQL and PHP.

I believe that an example of what I want to do here should be
interesting for many others.

Thanks in advance for any suggestions and examples.

Carl S.

Reply With Quote
  #2  
Old August 5th, 2001, 12:40 PM
joska joska is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Netherlands
Posts: 2 joska User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
By making a table for every country, you're making it extra difficult. Is there no way to put all the countries in one table by using an extra 'country'-field.
An even better design will be to make a table which consists of two fields: one 'country'-field and one field that contains the name of the table belonging to that country. In this case you can query this table to create the pulldown menu in an easy why, and after the user selected the country of his choice, you can open the table with the information of that specific country.

Reply With Quote
  #3  
Old August 6th, 2001, 12:31 PM
carl_se carl_se is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2001
Location: Sweden
Posts: 2 carl_se User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!

Thanks Joska for your reply

Yes, what you suggest can solve the problem,
but if we only look at the MySQL database
it's pre-built in a logical way:

- One Database
- One single table for each country data (this
also makes it easy to add more countries as
the database grows)
- Each table contains seven fields as follows:
- Location name
- Geographical longitude in printable format
- Geographical latitude in printable format
- Time equation (longitude measured in time)
- Geographical longitude in calculation format
- Geographical longitude in calculation format
- Location type (town, bay, dock, etc).

So if I add all tables together the database
will be one huge table, and all experience
says to me that it's easier and more efficient
to first identify one table out of many and
then search through it instead of searching
through one huge single table. Note: Each country
table is between 1 Mb to 10 Mb large!

So the problem as I see it, is with PHP and
HTML as such, and not the database.

I can accept the fact that the easiest way
to solve this is to to pre-define the table
names (country names) in the select pull-down
menu. However, the main problem is still there:
How to read-in the table names from the database,
list them in the select pull-down menu, let the
user choose one of the tables, then show an empty
field and have the user to write in a searchable
text (in this case a location name), then open
that table and search for any and all locations
found and list the other fields therein.

As I said in my earlier post, I know how to do
this with Perl/CGI and a textbased database, but
now want to learn how to do it with PHP and MySQL.

Any suggestions?


Per Dahlin

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > PHP and MySQL question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway