<?php
error_reporting(E_ALL ^ E_NOTICE);
//ini_set('display_errors', '1');
ini_set('max_execution_time',60);
$con=mysql_connect('localhost','root','');
$link=mysql_select_db('playsms');
if($_POST)
{
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . '/../../Classes/');
/** PHPExcel_IOFactory */
include('C:\xampp\htdocs\phpexcel\Classes\PHPExcel.php');
include('C:\xampp\htdocs\phpexcel\Classes\PHPExcel\IOFactory.php');
/** PHPExcel */
require_once 'C:\xampp\htdocs\phpexcel\Classes\PHPExcel.php';
/** PHPExcel_IOFactory */
require_once 'C:\xampp\htdocs\phpexcel\Classes\PHPExcel\IOFactory.php';
//include 'PHPExcel/IOFactory.php';
//create reader
//$inputFileName = $_GET['sel_file'];
$file=$_FILES['sel_file']['name'];
if(!$file)
{
$file="";
}
else
{
$target_path= "C:\\xampp\\htdocs\\playsms\\uploads\\";
$target_path=$target_path.basename($_FILES['sel_file']['name']);
if(move_uploaded_file($_FILES['sel_file']['tmp_name'],$target_path))
{
echo "The file ". basename( $_FILES['sel_file']['name']).
" has been uploaded";
}
else
{
echo "There was an error uploading the file, please try again!";
}
}
//$inputFileName = "C:\Users\SHIVA\Desktop\CM.2012.25.xls";
$inputFileName= $target_path;
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
//$objPHPExcel = $objReader->load($inputFileName);
//echo 'File ',pathinfo($inputFileName,PATHINFO_BASENAME),' has been identified as an ',$inputFileType,' file<br />';
//echo 'Loading file ',pathinfo($inputFileName,PATHINFO_BASENAME),' using IOFactory with the identified reader type<br />';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$sheet = $objPHPExcel->getActiveSheet()->toArray(null,true,true,true);
//var_dump($sheet);
//print_r($sheet);die;
$objsheet = $objPHPExcel->getActiveSheet();
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
$nrColumns = ord($highestColumn) - 64;
echo "<br>File ".$sheetTitle . " has ";
echo $nrColumns . ' columns';
echo $highestRow . ' rows.';
// Loop through each row of the sheetData in turn
for ($row = 6; $row <= $highestRow; ++ $row)
{ //echo "1"."\n" ;
//$myvar=max;
//for($i = 0; $i<=$highestRow; $i++)
// echo "2"."\n" ;
$val=array("i");
for ($col = 0; $col <= $highestColumnIndex; ++ $col)
{
$cell = $sheet->getCellByColumnAndRow($col, $row);
$val[] = $cell->getValue();
echo $cell->getvalue();
//echo"<br>";
}
//echo "<br><br><br>";
//echo $val[2];
//echo "<br><br><br>";
$data=0;
//$data = array();
//$data[]=array($val2);
for($i = 0; $i<$highestRow; $i++)
{
//for($j=0;$j<$col; $j++)
// {
if( $data <= $val[6])
{
$data=$val[6];
//mysql_query("SELECT max(rate) FROM `playsms_toolssimplerate` WHERE prefix=$val[12]");
//$data=$val[6];
//echo "<br><br><br>";
//$abc=$val[12];
//$query =mysql_query("SELECT max(rate) as rate FROM `playsms_toolssimplerate` WHERE prefix='$abc'");
//$query['rate'];
//$result=mysql_query($query);
// echo $query;
//$data=$result;
}
//}
}
//echo $data;
// echo "<br><br><br>";
// echo $val[12];
//extract($val);
//print_r(array_values($val));
//exit;
//echo "</br></br></br></br>";
$sql = "INSERT INTO playsms_toolssimplerate (dst,rate,mccmnc,prefix)
VALUES ('$val[2]- $val[4]','$data','$val[11]','$val[12]')";
//echo $sql."\n";
mysql_query($sql);
}
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<br />
<br />
<br />
<br />
<br />
<form action="" method="post" enctype="multipart/form-data" >
<table border="1" width="40%" align="center">
<tr >
<td colspan="2" align="center"><strong>Import Excel file</strong></td>
</tr>
<tr>
<td align="center">Excel File:</td>
<td><input type="file" name="sel_file" id="sel_file" value=upload file/></td>
</tr>
<tr >
<td colspan="2" align="center"><input type="submit" name="submit" id="button" value="Submit" /></td>
</tr>
</table>
</form>
</table>
<label></label></td>
</tr>
</table> If The Table Is Filled Then Delete This<br />
<a href="javascript:linkto('index.php?app=menu&inc=tools_simplerate&op=simplerate_upload')"><h><input type='submit' class='button' value='DELETE TABLE'></h3></a>
<br />
<br />
</body>
</html>
国、オペレーター、レート、prifix、mccmncを含むExcelファイルがあります。これには、国ごとに複数の国とオペレーターがあり、料金もかかります。ある国の最大レートを取得してから、同じオペレーターに追加する必要があります。