<?php
include 'db_coection.php';
include 'reader.php';
$file="sample.xls";
$coection=new Spreadsheet_Excel_Reader();
$coection->read($file);
$startrow=1;
$endrow=2;
$col1=1;
$col2=2;
$col3=3;
for($i=$startrow;$i<$endrow;$i++){
$rrt1= $coection->sheets[0]["cells"][$i][$col1]."<br>";
$rrt2= $coection->sheets[0]["cells"][$i][$col2]."<br>";
$rrt3= $coection->sheets[0]["cells"][$i][$col3]."<br>";
echo $rrt1;
echo $rrt2;
echo $rrt3;
}
if ($rrt1 == "Name" || $rrt2 == "job" || $rrt3 == "email") {
$x=2;
while($x<=$coection->sheets[0]['numRows']) {
$name = isset($coection->sheets[0]['cells'][$x][1]) ? $coection->sheets[0]['cells'][$x][1] : '';
$job = isset($coection->sheets[0]['cells'][$x][2]) ? $coection->sheets[0]['cells'][$x][2] : '';
$email = isset($coection->sheets[0]['cells'][$x][3]) ? $coection->sheets[0]['cells'][$x][3] : '';
$sql_insert="INSERT INTO users_details (id,name,job,email) VALUES ('','$name','$job','$email')";
$result_insert = mysqli_query($co,$sql_insert) or die(mysql_error());
$x++;
}
}
else {
echo "Not matching!";
}
?>
برچسب:
نویسنده: آیلین رضوانی