How to use phpmyadmin insert many simliar data

They have: 23 posts

Joined: Jul 2007

I want to test my website
I want insert some user account like such:
username password city
marble001 aaaaaa NewYork
marble002 aaaaaa NewYork
marble003 aaaaaa NewYork
............. ........ ...........
marble999 aaaaaa NewYork
there are a thousand account,
I don't want to insert one by one.
Do you have a good method.
Please tell me
Thanks a lot.

I highly recommend reliable web hosting

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Do you have to use phpmyadmin to do it? You could write a simple PHP script that could do it for you.

<?php
mysql_connect
('localhost', 'user_name', 'db_password');

mysql_select_db('db_name');

$password = 'aaaaaa';
$city     = 'NewYork';
$username = 'marble';

while(
$x < 1000)
{
   
$username = $username . $x;
   
$sql = \"INSERT INTO tblName (username, password, city) VALUES('$username', '$password', '$city');\";
    mysql_query(
$sql);
   
$x++;
}
    
?>

I think that would do it. Just make sure your host allows you to do a bunch of queries Wink. The username would be marble1, marble2 etc.

pr0gr4mm3r's picture

He has: 1,502 posts

Joined: Sep 2006

Here is what teammatt3's code looks like -> http://scripts.pr0gr4mm3r.net/query_ex.php
Somebody didn't run it before posting Wink . Change...

<?php
$username
= $username . $x;
$sql = \"INSERT INTO tblName (username, password, city) VALUES('$username', '$password', '$city');\";
?>

...to...
<?php
$new_username
= $username . $x;
$sql = \"INSERT INTO tblName (username, password, city) VALUES('$new_username', '$password', '$city');\";
?>

That will leave you with this.

If you want some more random data, you can try something like this.

You can copy any of these query outputs directly into phpMyAdmin's SQL window.

I also have a table of ~4000 records of sample user information if you want it.

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

I meant to do that Sticking out tongue

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.