Home Tutorialhelp Comment CSV upload by script

 
 

Comment

Willem
CSV upload by script,
May 19, 2009 at 8:48 PM

I'm searching for an upload script wich give the user the possibility to select from his computer a CSV-file.
Next is ofcourse the CSV goes into the Database/tabel by query.
============= code ========

include("connect2db.php");

if(!isset($_POST['option']))
{
echo $page;
}
elseif($_POST['option'] == "yes")
{
$dbLink = mysql_connect("$domain", "$login", "$password");
mysql_select_db("$database",$dbLink);
$sql = 'INSERT INTO `persons`';
$resultaat = mysql_query($sql, $dbLink);
$uploaddir = 'uploads/';
$uploadfile = $uploaddir . $_FILES['csvfile']['name'];
if (move_uploaded_file($_FILES['csvfile']['tmp_name'], $uploadfile))
{
print "<font face='arial'>Succesvol geupload. ";

$notice = 1;
chmod($uploadfile, 0777);
}
else
{
print "<font face='arial'>ERROR: Upload Fout. ";
$notice = 0;
}
$strdata = array();
$notice = 1;
if($notice == 1)
{
echo "\n sending Data...";
flush();
echo "</font>";
if (file_exists($uploadfile))
{
$fp = fopen($uploadfile, 'r') or die (" Cannot open the file");
$row = 1;
$handle = $fp;
while (($data = fgetcsv($handle, 10240, ";")) !== FALSE)
{
$num = count($data);

echo "<p> ".$num." fields in line ".$row.": <br /></p>\n";
$row++;
for ($c = 0; $c < $num; $c = $c + 1)
{

$data[$c] = str_replace(',', ' ', $data[$c]);
$data[$c] = str_replace(' ', ';', $data[$c]);
$str = $data[$c];
$strdata[] = explode(';', $str);

}
}
fclose($handle);
}
}
echo '<pre>';
print_r($strdata);
echo '</pre>';
}

===== end code ==========


View All Comments | View Tutorial
Advertisement
Related Tutorial and Articles
MySQL

SQL Bulk Insert csv
an example from 'SQL Bulk Insert CSV'.To understand and  grasp this example... SQL Bulk Insert csv       SQL Bulk Insert is used to import the records from csv  file 

SQL Question

phpmyadmin - upload csv files - SQL
phpmyadmin - upload csv files  i have database in phpmyadmin. i have upload one time in csv file. i need to another csv file in upload same table. i will try to do this but result is failed. (table rows and csv rows are same 

SQL Tutorial

SQL Bulk Insert Example
SQL Bulk Insert Example       SQL Bulk Insert Example is used to insert a bulk record... to create SQL Bulk Insert .To grasp this example we create a table 'Stu 

Programming Tutorials

SQL Bulk Insert Example
SQL Bulk Insert Example       SQL Bulk Insert Example is used to insert a bulk record to the table... Bulk Insert .To grasp this example we create a table 'Stu_Table'.  

JSP Tutorials

To Upload and insert the CSV file into Database
To Upload and insert the CSV file into Database... to upload a CSV file through JSP and insert it into the database. For this, we have created two jsp pages page.jsp and upload_page.jsp. The page.jsp is created 

Development process Questions

upload csv to mysql db using jsp upload
upload csv to mysql db using jsp upload  Hello all, Please give me the code to uplad .csv from jsp page and insert values into MySQl db. I have a table with 8 cloumns.(MDN--varchar(30),Otafdate date,crt varchar(30),dmdn 

JSP Servlet Questions

Upload CSV File into Columns of sql table using servlets and jsp
Upload CSV File into Columns of sql table using servlets and jsp  Hello sir, plz give me the code to upload csv file data into respective columns of table 

MySQL

SQL Bulk Insert
SQL Bulk Insert       SQL Bulk Insert is performed when you insert a records  or row to a table in a bulk. Understand with Example The Tutorial covers an example from 'SQL 

PHP Questions

PHP code for csv file upload into mysql
PHP code for csv file upload into mysql  I want to upload a file from my pc to mysql server using upload option. while i m selecting the csv file it ll be upload the mysql database. can u send me the coding? i have tried 

SQL Question

how to export the query result in SQL Server to .csv file?
how to export the query result in SQL Server to .csv file?  how to write table data into CSV file using SQL SERVER 2008 

Development process Questions

java, upload csv file - Development process
java, upload csv file  hi, i have a csv file having 29 colums, i want to upload that csv file to database. i need the code,, can u please send me... link: http://www.roseindia.net/jsp/upload-insert-csv.shtml Thanks 

PHP

Php Sql Script
Php Sql Script This example illustrates how to create the php sql script. In this example we create a table "emp_counter" with three column...;VALUES (1, 'sandeep', SYSDATE())";   mysql_query($insert 

Java Beginners

Exporting data from mysql to csv file
Exporting data from mysql to csv file  Hi friends.... I want to export the data from mysql to csv file... i am having 30 columns in my database.. Eg... example that retrieves the data from the database and save it into csv file 

MySQL

PHP SQL Script
; Understand with Example The Tutorial illustrate an example from 'PHP SQL Script... PHP SQL Script       PHP SQL Script is useful to perform the operation of SQL queries in PHP 

JSP Servlet Questions

reading a csv file from a particular row
reading a csv file from a particular row  how to read a csv file from a particular row and storing data to sql server by using jsp servlet 

SQL Question

Inserting Data into mysql - SQL
into the SQL category though under php. I need help with reading from a csv file (using php)and inserting the details in a mysql database. Lets take for instance, a csv file named books and a database table named books as well both 

SQL Question

sql - SQL
the example and also what is the data type for image in database.. pleas send the answer to me with example of table and servet.   Hi friend... connectionURL = "jdbc:mysql://192.168.10.211:3306/amar"; java.sql.Connection 

SQL Tutorial

MySQL PHP Insert
. Understand with Example The Tutorial illustrate an example on MySQL PHP Insert... the database:".mysql_error()); $sql="insert into mytable (Empid,Empname... MySQL PHP Insert       

MySQL

Mysql CSV
provides you an elaborate example on Mysql CSV. To understand and grasp example, we... Mysql CSV      ... file into database. Mysql CSV is used to load the text file and add to the table 

SQL Tutorial

PHP SQL Insertion
; PHP SQL Insertion is used to execute MySQL queries in PHP script. It is used to send insert query or command that adds the records to MySQL. Understand with Example The Tutorial illustrate an example from 'PHP SQL Insertion 

Java Beginners

How to load Arabic csv to MYSQL
How to load Arabic csv to MYSQL  I tried the following set session collation_database=utf8_general_ci; set session character_set_database=utf8... as "?????? ????????????????". I am sure that the csv file is encoded to utf8 

SQL Tutorial

PHP SQL Insert
an example from PHP SQL Insert . To understand the example, firstly we need... PHP SQL Insert       PHP SQL Insert is used to insert the record from HTML page to Mysql  

Development process Questions

csv file download
csv file download  Hello Every one, when user clicks download button I want to retrieve data from mysql database table in csv format using java.if... the following link: JSP Retrieve data from MySQL Database 

SQL Question

mysql - SQL
mysql  hi i want to export my data from mysql to excel using php script. pls help me  Hi Friend, Please visit the following link: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml Thanks 

Java Code Examples

Export Database table to CSV File
as writing into a CSV file. Here is a database table is to be extracted: Example...Export Database table to CSV File In this tutorial, you will learn how to retrieve data from database and save it to CSV File. The Comma-separated values 

SQL Question

insertion in SQL - SQL
static void main(String[] args) { System.out.println("Insert records example... = "INSERT employee (username)VALUES('"+str+"')"; System.out.println(sql + sql...insertion in SQL  Query is "insert into employee values('"+eno 

SQL Question

mysql - SQL
mysql  How to insert the check box values in mysql database through php 

Java Beginners

Exporting data from mysql into csv using jsp
Exporting data from mysql into csv using jsp  Hi friends.... I want to export the data from mysql to csv file using... i am having 30 columns in my... in csv file..if i export, am getting the csv file with all data in one row 

SQL Question

mysql table construction - SQL
mysql table construction  In MySql there is no pivot function... data. Example: table1 a,b,c chi, 12,xx nyc,15,xx atl,16,xx sf,17,xx, table2 xx, chi, nyc, atl, sf then insert data xx,chic, nyc, atl, sf 

SQL Question

MYSQL - SQL
MYSQL  how to select last row in table?(MYSQL databse)   How to select last row of the table in mySql Here is the query given below selects tha last row of the table in mySql database. SELECT * FROM stu_info 

Free SQL books

SQL Example, Codes and Tutorials
to the pass data value  back to the invoker.  SQL Bulk Insert Example  SQL Bulk Insert Example is used to insert a bulk record to the table... SQL Functions MySql Example 

SQL Tutorial

PHP SQL Insert Statement
The Tutorial illustrate an example from 'PHP SQL Insert Statement'. To understand and illustrate an example 'PHP SQL Insert Statement', we create a table 'stu... PHP SQL Insert Statement      

PHP Questions

php csv file uploding into mysql database table.
php csv file uploding into mysql database table.  hai friends, i... fields. i have one mysql database table with two files fields, when ever i am uploding csv file, i want to fetch the datas in corresponding fields in table. can 

Servlets

insert into statement in sql using servlets
insert into statement in sql using servlets   ... insert a value from a html form in the table stored in the database. ... we are going to insert the values. Now make one jsp page or  html page 

SQL Question

auto sql script - SQL
auto sql script  Is there a way of generating inserts scripts using the table structure for oracle database 

SQL Question

CSV tables
CSV tables  hello, What are CSV tables?   hii, CSV Tables cannot be indexed.CSV Tables are the special tables, data for which is saved into comma-separated values files 

JDBC

JDBC Batch Example With SQL Insert Statement
JDBC Batch Example With SQL Insert Statement: In this tutorial, we are discuss about insert SQL statement with the jdbc batch. First of all, we... SQL insert statement for save data in the datasource and add 

Java-Tutorials

Java Write To File CSV
a simple example which will demonstrate you how to write to csv file. To achieve... Output : When you will execute this example at first a file with extension .csv...Java Write To File CSV In this tutorial you will learn how to write to file 

Java Code Examples

Java Read CSV file
. Here is a csv file: Example import java.io.*; import java.util.*; public...Java Read CSV file In this tutorial, you will learn how to read csv file. CSV... and there is no need of using any API to read these files. In the given example, we have 

MySQL

PHP SQL Die
a message and exists from the current script. Understand with Example The Tutorial illustrate an example from 'PHP SQL Die'. To understand and grasp the example...;Error in selecting the database:".mysql_error()); $sql="Select 

MySQL

PHP SQL Injection Example
PHP SQL Injection Example     ... to insert the records to database. Understand with Example The Tutorial helps you to illustrate an example from 'PHP SQL Injection Example'. To understand 

Ant

Ant Script to Insert Data in Mysql Table
Ant Script to Insert Data in Mysql Table       This example illustrates how to insert data... from the sql driver. The second element <property name="sql.url"> 

PHP Questions

create dropdown cell in csv or excell from mysql data in php
create dropdown cell in csv or excell from mysql data in php  Hello sir i want to create drodown cell in csv from mysql data is this is possible or not? if this is posible please share answer or reference link Thanks 

SQL Question

java - SQL
java  how to insert image in MySQL database table. please give me code to insert the image. thank you very much.  Hi friend, package... { System.out.println("Insert Image Example!"); String driverName = "com.mysql.jdbc.Driver 

SQL Question

sql
sql  returning value from a store procedure in sql with example   Please visit the following links: http://www.roseindia.net/mysql/mysql5/stored-procedures-and-functions.shtml http://www.roseindia.net/sql/create 

MySQL

PHP SQL Query Insert
PHP SQL Query Insert       This example illustrates how to execute insert query in php application. To understand how to use sql insert queries in php, we have created 

SQL Question

BLOB - SQL
as BLOB in the mysql database and retrieve the image and display it in the web... connectionURL = "jdbc:mysql://localhost:3306/test"; Connection con=null... = con.prepareStatement("INSERT INTO image VALUES(?,?)"); File file = new File("C 

Java Server Faces Questions

Upload and insert the file contents - Java Server Faces Questions
the example at http://www.roseindia.net/jsp/upload-insert-csv.shtml Hope...Upload and insert the file contents  I want to browse and upload 2... to browse and upload CSV files using the browse and upload button. as soon as i 

JSP Tutorials

Download CSV File from Database in JSP
Download CSV File from Database in JSP  ... to download CSV  file from database in JSP.  In this example, we have... a webpage "viewcsv.jsp""  to display and download the CSV 

PHP

Php Sql Query Insert
Php Sql Query Insert  This example illustrates how to execute insert query with values in php application. In this example we create two mysql query for insert statement with separate values in the database table. The table before 

MySQL

PHP SQL Login Script
PHP SQL Login Script      ... script for login application. In this example, we have created a login application...;and password='$password'";   $result=mysql_query($sql 

Hibernate Questions

sql script generation - Hibernate
sql script generation  he show_sql shows the sql statements...?? is there any way to do that in hibernate? Generate the sql script for tables creation ?and if this available can i do it - generate the sql creation table 

SQL Question

SQL Query - SQL
SQL Query  Hi I would like to know how to create a SQL query... table. I created table 2 and defined the fields.I tried different types of insert statements but could not figure it out. Example Table1 

SQL Question

SQL
SQL Trigger query  Why we use the Trigger and what it's uses?  ... customized database management system. For example, you can use triggers to: 1..., user events, and SQL statements to subscribing applications 10)Restrict DML 

MySQL

SQL PHP
with Example The Tutorial illustrate an example from 'SQL PHP'. To understand... is used to execute the statement of mysql_query function. The server side script...=mysql_query($sql,$connection) or exit("Sql Error".mysql_error 

SQL Question

insert and retrive data and time - SQL
insert and retrive data and time  hello everybody . Is there any method in java so that we can insert current system time and then it can... default NULL, PRIMARY KEY (`id`) ) To insert current date and time 

SQL Question

SQL
SQL  what data type we use for the uploading the video and image files in MySQL server 2008 

JSP Servlet Questions

upload a file into database and progrm should support excel and text and csv file formats
upload a file into database and progrm should support excel and text and csv file formats  Hai all, I need a program to upload a file into database table... and the program should support .excel ,.txt ,.csv file formats. can 

PHP

PHP SQL Login Script
PHP SQL Login Script This Application illustrates how to create a php validation script for login application. In this example we create a login application...=mysql_query($sql);     $count=mysql_num_rows($result);   

SQL Question

SQL
a highly customized database management system. For example, you can use triggers..., user events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

SQL
a highly customized database management system. For example, you can use triggers... events, user events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

SQL
customized database management system. For example, you can use triggers to: 1... events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

Sql question
Sql question  How to display duplicate values in Sql?   Hi Friend, Please visit the following link: http://www.roseindia.net/sql/mysql-example/mysql-finding-duplicate-records.shtml Thanks 

JSP Tutorials

Export Data into CSV file uing JDBC in JSP
Export Data into CSV file uing JDBC in JSP       CSV file : A CSV file is commonly known... : 3.Create a Page ("CsvJdbcFile.jsp") to export data into  CSV 

Java-Tutorials

SQL GROUP BY Example
SQL GROUP BY Example In this section we will discuss about the group by statement in SQL. In this tutorial we will use MySQL for using the SQL statements... be used with or without the SQL aggregate functions written with the SELECT 

Programming Tutorials

Create After Insert Trigger in SQL
on the specified table. Understand with Example The Tutorial illustrate a example from 'Create After Insert Trigger in SQL'. In this Example, we create... Create After Insert Trigger in SQL    

Programming Tutorials

Create Before Insert Trigger in SQL
Create Before Insert Trigger in SQL       The Create Before Insert Trigger in SQL fires the trigger before we insert the value into the table. Understand with Example The given 

SQL Question

SQL
with example 

JSP Servlet Questions

how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
a program by using servlets.. the program is like this i upload a text and csv file.it was stored in perticular directory now i have to read the stored(.csv...how to read the values for text and csv files and store those values 

JDBC Questions

storing csv into oracle database
storing csv into oracle database  i want jsp code for storing csv file into oracle database 

MySQL

SQL Backup Script
SQL Backup Script       The Tutorial illustrate an example from 'SQL Backup Script'. To understand and grasp example we create a command for backup of  table 

MySQL

sql php array
illustrate an example from 'SQL PHP Array'. To understand and grasp the example we include a PHP server side script that create an array...;.$value; $sql_result=mysql_query($sql,$connection) or exit("Sql 

MySQL

PHP SQL Injection Attack
with Example The Tutorial illustrate an example from PHP SQL Injection...;]; $sql="insert into stu(name,class) values('".$name."',".$class.")"; mysql_query($sql,$connection) or exit("Sql 

SQL Question

mysql select statement - SQL
mysql select statement  i want to select id,name,age values from... a[]) { Connection con = null; String url = "jdbc:mysql... for more information with example http://www.roseindia.net/jdbc/ Thanks 

SQL Question

The INSERT INTO Statements in SQL?
The INSERT INTO Statements in SQL?  The INSERT INTO Statements in SQL?   Hi, The INSERT INTO statement is used to insert a new row or multiple rows into a table. SQL INSERT INTO Syntax INSERT INTO table_name VALUES 

SQL Question

Assigning variable in mysql - SQL
Assigning variable in mysql  i have tables purchase, serialtable and salesdetail. i want to create a trigger that will fire on insert on salesdetails...) )ENGINE=INNODB; create trigger tg_salesDetails before insert 

Java Beginners

how to sort multiple key columns in CSV file - Java Beginners
how to sort multiple key columns in CSV file  Hi Any one can assist how to sort the multiple key columns in CSV file? Any example will be appreciated. Thanks 

SQL Question

MySQl - SQL
MySQl   How to Remove password for root in MY SQl.....? Please Provide the steps Immediately 

SQL Question

sql - SQL
order by SQL Query  What is order by in SQL and when this query is used in SQL?Thanks!  Hi,In case of mysql you can user following query.Select salary from salary_table order by salary desc limit 3,1Thanks 

SQL Question

MySQL - SQL
MySQL  how to set a time to repeat a trigger in Mysql?  Hi Friend, Please visit the following links: http://www.roseindia.net/mysql/mysql5/triggers.shtml http://www.roseindia.net/sql/trigger/mysql-time 

SQL Question

mysql - SQL
mysql  hi sir i want to display first two person highest salary in mysql  Hi I am sending a link where u can find max function to find the maximum marks of student. http://www.roseindia.net/sql/sql-aggregate 

SQL Question

sql - SQL
(select,insert,update etc.), manipulate objects(DDL) and data(DML). PL/SQL... want query? 4.what is the diffrence between sql and plsql?  Hi Friend... HAVING n>1; Difference between SQL and PL/SQL: SQL is a structured query 

Ant

Ant Script to Update Mysql Table
Ant Script to Update Mysql Table       This example illustrates how to insert and update data... to connect from the sql driver. The second property  <property name="sql.url 

MySQL

SQL PHP Where
illustrate an example from 'SQL PHP Where'. To understand and illustrate the example we use PHP server side script that include host, user, password...;.$value; $sql_result=mysql_query($sql,$connection) or exit("Sql 

JDBC Questions

upload SQL BLOB and CLOB - JDBC
upload SQL BLOB and CLOB  Please explain upload SQL BLOB and CLOB 

SQL Tutorial

SQL
SQL - SQL Introduction     SQL - An Introduction to the Structured Query Language SQL stands for Structured Query Language (SQL), a standard language used for creating, updating, querying 

Quartz Tutorials

SQL _ Wildcards
; The Tutorial illustrate an example from SQL_Wildcards... SQL _ Wildcards       SQL wildcards are used for  searching one or more characters 

Java Beginners

HTML Form data into .CSV?
HTML Form data into .CSV?  how to store data from html form to csvfile in java 

Quartz Tutorials

SQL as Keyword
SQL as Keyword       The SQL Key word used in SQL are createTable,Insert into,select,delete... that you add to the table using insert into SQL Command.  Create 

Quartz Tutorials

SQL OR Operators
with Example The Tutorial illustrate an example from SQL OR Operator .In this we help you... SQL OR Operators      ...)) Insert data into Stu_Table The insert into add the records or rows 

Quartz Tutorials

SQL IN Operator
SQL IN Operator       SQL IN Operator helps you to specify multiple values in a WHERE Clause. Understand with Example The Tutorial illustrate an example from SQL 

Quartz Tutorials

SQL And Statement
with Example The Tutorial illustrates an example from SQL AND Statement... SQL AND Statement       The SQL AND operator is used to show you the filter records 

Quartz Tutorials

SQL AND Operators
with Example The Tutorial illustrates an example from SQL AND Operator. In this Tutorial, Table Stu_Table is created using create table statement. The insert... SQL AND Operators       

Quartz Tutorials

SQL Alias
from 'SQL Alias'. To grasp this example, we create a table 'Stu_Table... SQL Alias       SQL Alias is the another name given to the existing table 

SQL Question

mysql - SQL
mysql  hi i am using mysql. i want to create simple table...=INNODB; For more information MySql visit to : http://www.roseindia.net/mysql/ Thanks 

Quartz Tutorials

SQL Alias
. Understand with Example The Tutorial illustrate an example to understand SQL Alias... Alias Query The given below example show you the SQL Alias Query... SQL Alias       

Quartz Tutorials

SQL ORDER BY
. Understand with Example The Tutorial illustrates an example from SQL ORDER BY. In this example, we create a table 'Stu_Table'. The create... SQL ORDER BY       

MySQL

sql php code
; SQL PHP code executes the statement using the mysql_query ( ) function... with Example The Tutorial illustrate an example from 'SQL PHP'. To understand... the statement of mysql_query function. The server side script retrieve the records 

SQL Question

sql - SQL
sql functions with examples  I need sql functions with examples... = "jdbc:mysql://localhost:3306/"; String db = "register"...("SQL statement is not executed!"); } } catch (Exception e 

MySQL

SQL Add Column Position
Column Position' in Mysql. To understand and grasp the example we simply create... with Example The Tutorial illustrate an example from 'SQL Add Column Position... SQL Add Column Position       

Advertisements Advertisements
 

 

 

DMCA.com