表单HTML代码:
<p style="margin:10px 0"><a href="export.php" class="btn">导出</a></p> <form action="import.php" method="post" enctype="multipart/form-data"> <div class="control-group"> <label>Excel表格:</label> <input type="file" name="file"/> </div> <div class="control-group"> <input type="submit" value="导入" /> </div> </form>
PHP之excel导出
$query = mysql_query("select * from user limit 50"); $i =0; $list = array(); while($row=mysql_fetch_array($query)){ $list[$i]['id'] = $row['id']; $list[$i]['username'] = $row['username']; $list[$i]['password'] = $row['password']; $i++; } $title = array('ID', '邮箱', '密码'); //设置要导出excel的表头