<?php
/////////////////////////////// connect database ///////////////////////////////////////
$mysqlhost=”localhost”;
$mysqldb=”uni”;
$mysqluser=”root”;
$mysqlpwd=””;
$link = mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd, $mysqldb);
if (!$link) {
echo “Error: Unable to connect to MySQL.” . PHP_EOL;
echo “Debugging errno: ” . mysqli_connect_errno() . PHP_EOL;
echo “Debugging error: ” . mysqli_connect_error() . PHP_EOL;
exit;
}
//////////////////////////////////////////////////////
@$StNumber=$_POST[“StNumber”];
@$Fname=$_POST[“Fname”];
@$Lname=$_POST[“Lname”];
@$IdNumber=$_POST[“IdNumber”];
?>
<!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>test kelas</title>
</head>
<body>
<form method=”post” action=”<?php echo @$PHP_SELF; ?>” enctype=”multipart/form-data”>
<center>
<table border=”0″>
<tr>
<td><input name=”StNumber” type=”text” /></td>
<td>شماره دانشجویی</td>
</tr>
<tr>
<td><input name=”Fname” type=”text” /></td>
<td>نام دانشجویی</td>
</tr>
<tr>
<td><input name=”Lname” type=”text” /></td>
<td>نام خانوادگی دانشجویی</td>
</tr>
<tr>
<td><input name=”IdNumber” type=”text” /></td>
<td>شماره ملی</td>
</tr>
<tr align=”center”>
<td colspan=”2″>
<input name=”ذخیره” type=”submit” value=”ذخیره” />
<input name=”خذف” type=”submit” value=”حذف” />
<input name=”جستجو” type=”submit” value=”جستجو” />
</td>
</tr>
</table>
<table border=”1″ width=”90%”>
<tr align=”center”>
<td align=”center”>شماره دانشجویی</td>
<td align=”center”>نام دانشجویی</td>
<td align=”center”>نام خانوادگی دانشجویی</td>
<td align=”center”>شماره ملی</td>
</tr>
<?php
$query=”SELECT StNumber,Fname,Lname,IdNumber FROM `student`”;
if($StNumber!=null)
{
$query=”SELECT StNumber,Fname,Lname,IdNumber FROM `student` where StNumber=’$StNumber'”;
}
$result =mysqli_query($link,$query) or die(mysql_error());
while($row = mysqli_fetch_array($result ))
{
$StNumber= $row[“StNumber”];
$Fname= $row[“Fname”];
$Lname= $row[“Lname”];
$IdNumber= $row[“IdNumber”];
?>
<tr align=”center”>
<td align=”center”><?php echo $StNumber ?></td>
<td align=”center”><?php echo $Fname ?></td>
<td align=”center”><?php echo $Lname ?></td>
<td align=”center”><?php echo $IdNumber ?></td>
</tr>
<?php
}
?>
</table>
</center>
</form>
</body>
</html>
//////////////////////////////////////////////////////////////////////////////