Home >php教程 >php手册 >php读取excel并查询指定数据

php读取excel并查询指定数据

WBOY
WBOYOriginal
2016-05-26 15:21:522968browse

<html><heae>           
<title>php教程读取excel并查询指定数据</title>           
<body><center>成绩查询系统<hr>           
<table border=0><tr>           
<td bgcolor=red align=center)成绩查询系统输入界面</td>           
<td bgcolor=tintyellow align=left rowspan=2>说明 :<br>          
请输入正确且完整的数据.<br>          
本查询系统仅供参考,实际以成绩单为准.<br>          
例如:查询 2001 学年第一学期二专资管科一年级一班<br>      
学号输入格式范例:c017037<br>          
<br></td><tr>          
<td bgcolor=tintblue align=center><center><form action=nscore.php method=get>          
<select name=pl>          
<option value=2001>2001          
<option value=2002>2002          
<option value=2003>2003          
<option value=2004>2004          
</select)学年第          
<select name=p2>          
<option value=1>一          
<option value=2>二          
</select>学期<br>          
<select name=p3>          
<option value=1>二专          
<option value=2>二技           
<option value=3>四技          
</select>学制          
<select name=p4>          
<option value=1>电子                           
<option value=2>电机          
<option value=3>机械          
<option value=4>土木          
<option  value=5>经管          
<option value=6>环工          
<option value=7>资管          
<option value=8>应外          
</select>系/科          
<select name=p5>          
<option value=1>一          
<option value=2>二          
<option value=3>三          
</select>年级          
<select name=p6>          
<option value=1>一          
<option value=2>二          
<option value=3>三          
<option value=4>四          
</select>班<br>          
<b>学号:</b><input size=10 name=no><br><br>          
<input type=submit value=确定 name=submit>          
</form>          
</center></td>          
</tr>          
</table>          
<hr>              
</body></html>

//php代码 

<?php
$filename = $pl . $p2 . $p3 . trim($p4) . trim($p5) . trim($p6) . ".dbf";
if (file_exists($filename)) ($f = dbase_open($fiiename, 0);
$k = dbase_get_record($f, 1);
for ($i = 2; $i < dbase_numrecords($f); $i++) {
    $a = dbase_get_record($f, $i);
    if ($no == trim($a[0])) {
        echo "<html><center>成绩查询系统";
        echo "<hr>";
        echo "$a[0] $a[1]<br>";;
        echo "<table border=1>";
        echo "<tr><td><center>科目名称</td><td)<center>分数</td>";
        for ($j = 2; $j < (dbase_numfields($f)); $j++) {
            echo "<tr><td><center>$k[$j]</td><center>$a[$j]</td>";
        } //end for j
        break;
    } //end if
    
} //end for i
echo "</tr>";
dbase_close($f);
} else {
    echo "错误信息:成绩数据库教程尚未建立<br>";
} //开源代码phprm.com
if ($no == "") {
    echo "错误信息:请输入学号<br>";
}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn