473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Table and PHP scripts for existing data

I've been using MySQL for several months and enjoyed great success
when installing other people's scripts to databses I make using
phpMyAdmin.

My challenge is developing from scratch the scripts, for which I've
got good resources, manuals, and much time into practice and test.

My question is three-fold, as I have 14,000 records of Security
Dealers that I want to install in MySQL at www.securitydealers.com

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",

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

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?
Jul 17 '05 #1
1 1956
I noticed that Message-ID:
<cb**************************@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/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Murtix Van Basten | last post by:
HI all, I am trying to migrate a database from mysql to mssql2k. I use myODBC to connect to mysql server to pull the database from DTS and insert in to sql server. But in mysql server, there is...
2
by: me | last post by:
I would like to add an Identity to an existing column in a table using a stored procedure then add records to the table and then remove the identity after the records have been added or something...
7
by: Jon Combe | last post by:
I have created the following test SQL code to illustrate a real problem I have with some SQL code. CREATE TABLE JCTable ( CustomerName varchar(50) ) ALTER TABLE JCTable ADD CustomerNo int...
21
by: Dan | last post by:
Hi, just ran into my first instance of a backend Access97 database not compacting. I'm getting the "MSACCESS.EXE has generated errors.." message on compact. I've narrowed it down to the largest...
1
by: Michael | last post by:
I have a query that uses two joined tables. The query contains data. I would like to pull in a data drom another table but when I add that table to the query design and make the join,the existing...
4
by: Scot L. Harris | last post by:
Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0 system. I am writing some php scripts where I want to generate a list of the column names in a particular table that...
1
by: Greg | last post by:
Hi, I need to implement a table in XBRL. Let's assume I have 2 simple tables to define: TABLE 1 col1 col2 row1 A C row2 B D TABLE 2
15
by: Piero 'Giops' Giorgi | last post by:
Hi! I have a question: I already have a DB that uses partitions to divide data in US Counties, partitioned by state. Can I use TWO levels of partitioning? I mean... 3077 filegroups and...
5
by: yeoj13 | last post by:
Hello, I have a db2load script I'm using to populate a large table. Ideally, my target table is required to have "Not Null" constraints on a number of different columns. I've noticed a ...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.