GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jun-2004, 16:07
meeusen meeusen is offline
New Member
 
Join Date: Jun 2004
Posts: 2
meeusen is on a distinguished road

filling database


Hi

I am filling my database with a couple of thousend
8 digits numbers. These numbers i have in a list in a text-file.
Also I have a dump-sql file that i fill with these numbers by copying and pasting the numbers in between the brackets after the word VALUES in the following sentence:

INSERT INTO NUMBERS (number) VALUES ();

resulting in;

INSERT INTO NUMBERS (number) VALUES (01234567);

That i repeat with all the numbers

This takes me forever.....!

Is their anybody who knows a quicker way...?
I would appriciate any suggestions deerly!

Greetings

Meeusen
  #2  
Old 11-Jun-2004, 19:48
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Hello meeusen,

Yes, it's wise for you to seek an alternative solution to what you're trying to do.

This is a fairly common solution by the way, so you can start with this suggestion and extend on it with whatever details you need to add to it.

First, you've got to get the data off that text file into a (numerically indexed) array in your script - for example, it could end up looking like:

PHP Code:

<?php
$data[0]  = 12345678;
$data[1]  = 23456789;
$data[2]  = 34567890;
// etc.
?>


Next, you will start to build your INSERT SQL string... this can be easily done many ways but here's one, just to give you an idea...

PHP Code:

<?php
// at this point, you already have READ (the text file) and filled in the 8 digits numbers into an array named $data, see example above;

$SQL  = "INSERT INTO `numbers`
            ( `number` )
            VALUES (";
// here we add all the "values" off $data
$SQL  .= implode( '),(', $data );
// close the SQL string;
$SQL  .= ')';

// just to see if everything is alright with this SQL string; we display it for now...
///*
echo $SQL;
//*/

// otherwise you can run it...
/*
  $result = mysql_query( $SQL, $conn );
//*/
?>

  #3  
Old 12-Jun-2004, 05:12
meeusen meeusen is offline
New Member
 
Join Date: Jun 2004
Posts: 2
meeusen is on a distinguished road
Excellent

thank you very much
 
 

Recent GIDBlogProblems with the Navy (Chiefs) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Database search misunderstood MySQL / PHP Forum 11 04-Jun-2004 13:21
Help choosing a database for home network pcxgamer Open Discussion Forum 13 23-May-2004 15:47
Parsing PHP code that's stored in a database. JdS MySQL / PHP Forum 3 13-May-2004 10:15
insert data into database jilshi Web Design Forum 0 29-Apr-2004 23:47
WInXp Apache database? Ticoloco Apache Web Server Forum 1 27-Nov-2003 05:21

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:58.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.