วันอาทิตย์ที่ 1 ธันวาคม พ.ศ. 2556

PHP : 2.12.56

"connect"

<?
$host   = "localhost";
$dbuser = "root";
$dbpass = "1234";
$link = mysql_pconnect($host,$dbuser,$dbpass) or die(mysql_error());

mysql_select_db("12345db",$link) or die(mysql_error());

mysql_query("SET NAMES UTF8");

?>

"index"

<?php require("connect.php"); ?>
<!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>

<?php
$sql ="select * from student order by id asc ";
$query=mysql_query($sql) or die(mysql_error());
$num=mysql_num_rows($query);
echo "จำนวนทั้งหมด".$num;."คน";
?>

<center>
<table width="342" border="1">
  <tr>
    <td width="76">ลำดับ</td>
    <td width="57">รหัส</td>
    <td width="187">ชื่อ-สกุล</td>
  </tr>
  <?php
  $i=0;
  while($rs=mysql_fetch_array($query)){
  $i++;
  ?>
  <tr>
    <td><div align="center"><?php echo $i;?></div></td>
    <td><div align="center"><?php echo $rs["id"];?></div></td>
    <td><div align="center"><?php echo $rs["title"]."".$sr["name"]."".$rs["surname"];?></div></td>
  </tr> <?php }?>
</table>
</center>

</body>
</html>



"login"

<!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>
<script language="javascript">
function check(){
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="logincheck.php" onsubmit="return check()">
  <table width="500" border="1" align="center">
    <tr>
      <td width="151"><div align="left"></div></td>
      <td width="333"><div align="center">เข้าสู่ระบบ</div></td>
    </tr>
    <tr>
      <td><div align="right">รหัสประจำตัว</div></td>
      <td><div align="center">
        <input name="id" type="text" id="id" maxlength="5" />
      </div></td>
    </tr>
    <tr>
      <td><div align="right">รหัสผ่าน</div></td>
      <td><div align="center">
        <input name="password" type="password" id="password" maxlength="9" />
      </div></td>
    </tr>
    <tr>
      <td><div align="right"></div></td>
      <td><div align="center">
        <input type="submit" name="button" id="button" value="Submit" />
        <input type="submit" name="button2" id="button2" value="Cancle" />
      </div></td>
    </tr>
  </table>
</form>
</body>
</html>