Jump to content

Insert long list into phpmyadmin table


dc_jt

Recommended Posts

<?php

$name = array("john", "david", "james", "linda");
$password = "??";

for ($i=0; $i < count($name); $i++){

   mysql_query("INSERT INTO table (name, password) VALUES ('$name[$i]', '$password')");

}

?>

 

I'm not sure if you already have the values of user_id and password already filled in for these people, or if you are trying to add all completely new rows? This code adds all completely new rows.

Well, if you have all these names in a text file there is a way to pull them all out using fopen() and then putting them all into an array....but I don't have time to put the script together for you. There are plenty of tutorials out there that explain how to do this though, just google it and I am sure you will find something. Maybe someone else can help you =]

 

You might want to give an example of what your text file looks like. Like are the names separated by commas, spaces, or what? Just copy and paste like 5 names from the file to show us how you set it up.

 

I will be back on later if you still need the help, I am sure someone will come along and help you though ^^

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.