Reputation: 412
How to load some data from an CSV file to an html/php page?
.
The CSV file contains the data such as 'username','emailid','phone number'. These three parameters in each row, that should be loaded to an html/php page. Also, I need to write back 'username','emailid','phone number' to excel sheet. Is this can be done?(CSV to HTML page loaded).
And, I need to search each elements, in row-wise.
Upvotes: 0
Views: 2844
Reputation: 1292
i do agree with LcLk that it's not robust way , but yes there are some class available like PHPExcel and excelReader in php by that you can achieve it !!!
do Find the link below
Upvotes: 1
Reputation: 193
convert the excel sheet to csv file and then you can do it like this
$handle = fopen("yourexcel.csv",'r');
if(!$handle) die('Cannot open uploaded file.');
//Read the file as csv
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$username = $data['0'];
$email = $data['1'];
$phonenumber = $data['2'];
here data[0],data[1] are the columns of the excel sheet
if(strlen($username ) || strlen($email) || strlen($phonenumber)){
$query2 = "insert into user_master(username,email,phonenumber) values ('".$username."','".$email."','".$phonenumber."');";
mysql_query($query2);
}
Then you can retreive the data from your DB and dipplay in your project where ever you needed
Upvotes: 1