Reputation: 68
I am importing a CSV file which contains 2 fields. But as it is imported, I want that there should be an increment in transactionid. But this id field is not in file. Code for this is in PHP. Database used is MySql. My Code:
do
{
if ($data[0])
{
mysql_query("INSERT INTO test VALUES
(
'".addslashes($data[0])."',
'".addslashes($data[1])."'
)
");
}
}
while ($data = fgetcsv($handle,1000,";"));
Upvotes: 3
Views: 993
Reputation: 396
ok try this code
do
{
if ($data[0])
{
mysql_query("INSERT INTO test(table name) VALUES
('".addslashes($data[0])."','".addslashes($data[1])."')
");
}
}
while ($data = fgetcsv($handle,1000,";"));
Upvotes: 0
Reputation: 396
You need to specify the name of that table where you really want to import in query.
Upvotes: 1
Reputation: 1061
In your table on the id
column, set the auto_increment
parameter to true/active.
Upvotes: 1