把select * from student裏的student改成數據庫裏學生信息對應的表名
把where id = 中的id改成數據庫裏面對應學號的字段名
把$row['name']和$row['class']裏的name和class也對應的改掉就可以用了
文件內容:
<?
if(isset($_POST["submited"]))
{
$student_no = $_POST["s_no"];
$sql = "select * from student where id = $student_no";
mysql_connect('localhost','php','php');
mysql_select_db('php_kaoshi');
$query = mysql_query($sql);
$row = mysql_fetch_row($query);
echo "姓名:${row['name']} <br /> 學號:$student_no <br /> 班級: ${row['class']}";
}
else
{
><form action="GetFen.php" method="post">
<input type="hidden" name="submited" value="1" />
<input name="s_no" type="text" /><button type="submit">查詢</button>
</form>
<?php
}
>