Re: Table and PHP scripts for existing data

From: Geoff Berrow (blthecat_at_ckdog.co.uk)
Date: 03/11/04


Date: Thu, 11 Mar 2004 17:31:34 +0000

I noticed that Message-ID:
<cbc70ed4.0403110727.2a0625e7@posting.google.com> from Aaron contained
the following:

>
>1) what should my table SQL statement look like for data (sample) as
>follows;
>
> "John Doe","Managing Partner","BM SECURITIES LTD.","P.O. Box
>201","Grand Cayman","Cayman Islands,"","","345--555-5999",

You already said you used phpMyAdmin. Set the table up using that. I'd
include a primary key that is an integer and set it to auto_increment.
Everything else is a VARCHAR (yes, even the phone number) I'll leave it
to you to decide what length. What about the two fields with no data?
What are they for?

>
>2) once the table is created inside my database on MySQL, how do I
>load the data in?

Assuming the data is a .csv or a .txt file you upload it and then us e a
scrtipt similar to the one below

In this case the file is called query1.txt

# Connect to the database
mysql_connect('host',user,pass);

# Delete the current content of the table
$result = mysql_db_query($sql_db,"DELETE FROM $table") or die ("Invalid
DELETE query");

# Optimize the current table (recover empty space)
$result = mysql_db_query($sql_db,"OPTIMIZE TABLE $table") or die
("Invalid OPTIMIZE query");

# Load local comma separated, fields enclosed by quotes text database -
File has to be in the same directory of this file
$result = mysql_db_query($sql_db,"LOAD DATA LOCAL INFILE 'query1.txt'
INTO TABLE $table FIELDS TERMINATED BY ';' ENCLOSED BY ''") or die
("Invalid DATA LOAD query");

# Get how many records are present in the table now
$result = mysql_db_query($sql_db,"SELECT * from $table") or die
("Invalid SELECT query");
$rows_count = mysql_num_rows($result);

echo "Records: $rows_count"; mysql_free_result($result);

?>
>
>3) what is the best choice of variables, operators and arrays for my
>PHP script, to display only records from a certain city, country,
>company name or Dealer name?

I think you need to work your way through a PHP/MySQL tutorial

Try http://hotwired.lycos.com/webmonkey/99/21/index2a.html

-- 
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/


Relevant Pages

  • Re: Slow form, again
    ... subforms if you think the problem might lie there. ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... If it's not my database I'm not sure what to tell my co-workers and boss ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Segment: Control Source Business_Segment/Row Source ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... If it's not my database I'm not sure what to tell my co-workers and boss ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Thanks everyone for the posts. ... It is over a LAN and the form is bound to a query. ... Removing all subforms gets the form to load in about 15 seconds. ... database, and same brick wall! ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... database, and same brick wall! ... seconds to load. ... My form pulls off a query (query takes about 10 ... "Delete the SQL from the RecordSource and RowSource properties ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Slow form, again
    ... Is the below query what the Parent form is based on? ... Removing all subforms gets the form to load in about 15 seconds. ... database, and same brick wall! ... "Delete the SQL from the RecordSource and RowSource ...
    (microsoft.public.access.tablesdbdesign)