1. ចូលទៅ http://127.0.0.1/phpMyAdmin/
2. បង្កើតមូលដ្ឋានទិន្នន័យមួយឈ្មោះ project
3. បង្កើតតារាងមួយឈ្មោះ student ដែលមានចំនួន 12 ជួរឈរ
4. បំពេញទិន្នន័យ ក្នុងតារាង student ដូចរូបខាងក្រោម
5. បញ្ចូលទិន្នន័យក្នុងតារាង (អ្នកអាចអនុវត្តតាមឧទាហរណ៍ ឬបញ្ចូលទិន្នន័យផ្សេងដែលអ្នកចង់បញ្ចូល)
6. បន្ទាប់ពី បង្កើតមូលដ្ឋានទិន្នន័យរួចហើយ ឥឡូវចាប់ផ្តើមសរសេរកូដ
ចូលទៅ C/Apperv/www ហើយបង្កើត folder មួយឈ្មោះ project
7. នៅក្នុង folder project បង្កើត folder មួយទៀតឈ្មោះ image
8. ទាញយករូបភាពខាងក្រោម ទុកនៅក្នុង folder image
9. សរសេរកូដ config.php ដើម្បីតភ្ជាប់ទៅមូលដ្ឋានទិន្នន័យ
<?php
/* Database Connection */
$sDbHost = 'localhost';
$sDbName = 'work';
$sDbUser = 'root';
$sDbPwd = '1234567';
$dbConn = mysql_connect ($sDbHost, $sDbUser, $sDbPwd) or die ('MySQL connect failed. ' . mysql_error());
mysql_select_db($sDbName,$dbConn) or die('Cannot select database. ' . mysql_error());
?>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា config.php នៅក្នុង folder project ។
10. សរសេរកូដ colorstly.php ដើម្បីរចនាពណ៍
<?php
$htable="#CCCCCC";
$dtable2="#63B8FF";
$dtable3="#B0E0E6";
?>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា colorstly.php នៅក្នុង folder project ។
11. សរសេរកូដ footer.php ដើម្បី បញ្ចប់ខាងក្រោមវែបសាយ
</td>
</tr>
</table>
</body>
</html>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា footer.php នៅក្នុង folder project ។
12. សរសេរកូដ header.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><?php echo $localsystem_name;?></title>
<script language="javascript">
//+++++++++++++++++++++++++++++++++++++++++
function linkpage(linkp){
document.location="<?php echo $www_url;?>"+linkp;
}
//+++++++++++++++++++++++++++++++++++++++++
function dodelete(filename){
wait=true;
if (confirm("<?php echo $str_dodelete;?>")) {
document.location="<?php echo $www_url;?>/"+filename;
return true;
} else {
return false;
}
}
//+++++++++++++++++++++++++++++++++++++++++
</script>
</head>
<body>
<table border="0" width="100%" height="100">
<tr bgcolor="<?php echo $dtable1;?>">
<td colspan="2" height="100" >
<?php //echo $localsystem_name;?>
<img src="./image/banner.jpg" width="100%"/>
<br/></td>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា header.php នៅក្នុង folder project ។
12. សរសេរកូដ view_student.php ដើម្បីបង្ហាញបញ្ជីឈ្មោះរបស់និស្សិត
<?php include("config.php"); ?>
<?php include("./connectdb.php"); ?>
<?php include("./header.php"); ?>
<!----------------- HEAD PAGE ------------------------>
<br />
<!--------------------------------------------------------->
<table border="0" width="70%" height="100" align="center">
<?php include("./search_student.php"); ?>
<table border="0" width="70%" height="100" align="center">
<td colspan="2" height="20" align="center">
<?php //echo $localsystem_name;?>
<img src="./image/lists.jpg" width="25%"/></td>
</table>
<table width="90%" border="0" align="center">
<tr bgcolor="<?php echo $htable;?>">
<th width="3%">No.</th><th width="15%">First name</th><th width="15%">Last name</th><th width="20%">Major</th><th width="30%">Institute</th><th width="25%">From</th>
</tr>
<?php
$rtable=$dtable2;
//sel sql statment
$sql = "select * from student";
//send sql to process
$result = $mysqli->query($sql) or die($mysqli->error.__LINE__);
while($row = mysqli_fetch_array($result)) {
$stu_id= $row["stu_id"];
$stu_fname= $row["stu_fname"];
$stu_lname=$row["stu_lname"];
$stu_major= $row["stu_major"];
$stu_institue=$row["stu_institute"];
$stu_from=$row["stu_from"];
if($rtable==$dtable3){
$rtable=$dtable2;
} else {
$rtable=$dtable3;
}
?>
<tr bgcolor="<?php echo $rtable;?>">
<td align="center"><?php echo $stu_id;?></td>
<td ><?php echo $stu_fname;?></td>
<td ><?php echo $stu_lname;?></td>
<td align="center"><?php echo $stu_major;?></td>
<td align="center"><?php echo $stu_institue;?></td>
<td align="center"><?php echo $stu_from;?></td>
</tr>
<?php
}
?>
</table>
<!--------------------------------------------------------->
<?php include("./footer.php"); ?>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា view_student.php នៅក្នុង folder project ។
13. សរសេរកូដ search_student.php ដើម្បីបង្កើតប៊ូតុង ស្វែងរក ដោយខ្ញុំបានសរសេរ កូដ css ក្នុងការរចនាប៊ូតុង បន្ទាប់មក ប្រើ class ដើម្បីប្រើប្រាស់ css ហើយ ការស្វែងរក មាន 3 ប្រភេទ អាចជ្រើសរើស ស្វែងរក ដោយឈ្មោះរបស់និស្សិត ឬ មុខវិជ្ជារបស់និស្សិត ឬ វិទ្យាស្ថានសិក្សារបស់និស្សិត
<html>
<head><title>Search Student</title></head>
<style>
.myButton {
-moz-box-shadow:inset 0px 1px 0px 0px #dcecfb;
-webkit-box-shadow:inset 0px 1px 0px 0px #dcecfb;
box-shadow:inset 0px 1px 0px 0px #dcecfb;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #bddbfa), color-stop(1, #80b5ea));
background:-moz-linear-gradient(top, #bddbfa 5%, #80b5ea 100%);
background:-webkit-linear-gradient(top, #bddbfa 5%, #80b5ea 100%);
background:-o-linear-gradient(top, #bddbfa 5%, #80b5ea 100%);
background:-ms-linear-gradient(top, #bddbfa 5%, #80b5ea 100%);
background:linear-gradient(to bottom, #bddbfa 5%, #80b5ea 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#bddbfa', endColorstr='#80b5ea',GradientType=0);
background-color:#bddbfa;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #84bbf3;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #528ecc;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #80b5ea), color-stop(1, #bddbfa));
background:-moz-linear-gradient(top, #80b5ea 5%, #bddbfa 100%);
background:-webkit-linear-gradient(top, #80b5ea 5%, #bddbfa 100%);
background:-o-linear-gradient(top, #80b5ea 5%, #bddbfa 100%);
background:-ms-linear-gradient(top, #80b5ea 5%, #bddbfa 100%);
background:linear-gradient(to bottom, #80b5ea 5%, #bddbfa 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#80b5ea', endColorstr='#bddbfa',GradientType=0);
background-color:#80b5ea;
}
.myButton:active {
position:relative;
top:1px;
}
</style>
<style>
.myButton1 {
-moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
-webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7;
box-shadow:inset 0px 1px 0px 0px #54a3f7;
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7));
background:-moz-linear-gradient(top, #007dc1 5%, #0061a7 100%);
background:-webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%);
background:-o-linear-gradient(top, #007dc1 5%, #0061a7 100%);
background:-ms-linear-gradient(top, #007dc1 5%, #0061a7 100%);
background:linear-gradient(to bottom, #007dc1 5%, #0061a7 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#007dc1', endColorstr='#0061a7',GradientType=0);
background-color:#007dc1;
-moz-border-radius:3px;
-webkit-border-radius:3px;
border-radius:3px;
border:1px solid #124d77;
display:inline-block;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:13px;
padding:6px 24px;
text-decoration:none;
text-shadow:0px 1px 0px #154682;
}
.myButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1));
background:-moz-linear-gradient(top, #0061a7 5%, #007dc1 100%);
background:-webkit-linear-gradient(top, #0061a7 5%, #007dc1 100%);
background:-o-linear-gradient(top, #0061a7 5%, #007dc1 100%);
background:-ms-linear-gradient(top, #0061a7 5%, #007dc1 100%);
background:linear-gradient(to bottom, #0061a7 5%, #007dc1 100%);
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0061a7', endColorstr='#007dc1',GradientType=0);
background-color:#0061a7;
}
.myButton:active {
position:relative;
top:1px;
}
</style>
<body>
<form method="get" action="view_search_student.php"> <p>
<select class ="myButton1" name= "list">
<option class ="myButton" value="stu_fname">Search Firstname
<option value="stu_major">Search Major
<option value="stu_institute">Search Institute
</select >
<input type="text" name="search" >
<input type="submit" class ="myButton" value="Search">
</form>
</body>
</html>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា search_student.php នៅក្នុង folder project ។
14. សរសេរកូដ view_search_student.php ដើម្បីបង្ហាញបញ្ជីដែលអ្នកស្វែងរក
<?php include("./header.php"); ?>
<?php include("./colorstly.php"); ?>
<table width="90%" border="0" align="center">
<tr bgcolor="<?php echo $htable;?>">
<th width="3%">No.</th><th width="15%">First name</th><th width="15%">Last name</th><th width="20%">Major</th><th width="30%">Institute</th><th width="25%">From</th>
</tr>
<?php
$link=mysql_connect("localhost","root","1234567");
if (!$link)
{
print("ERROR");
}
else
{
mysql_select_db("project",$link);
$rtable=$dtable2;
//sel sql statment
$sql = "select stu_id , stu_fname , stu_lname , stu_major , stu_institute, stu_from from student where $list like '$search%'";
//send sql to process
$res = mysql_query( $sql , $link );
while( $row=mysql_fetch_row($res)){
if($rtable==$dtable3){
$rtable=$dtable2;
} else {
$rtable=$dtable3;
}
echo("<tr bgcolor='$rtable'><td>$row[0]</td> <td>$row[1]</td> <td>$row[2]</td> <td>$row[3] </td>
<td>$row[4]</td> <td>$row[5]</td></tr> ");
?>
<?php
}
}
?>
</table>
<!--------------------------------------------------------->
<?php include("./footer.php"); ?>
អនុវត្តតាម កូដខាងលើ ហើយ save ឈ្មោះថា view_search_student.php នៅក្នុង folder project ។
15. ចូលទៅ web browser ហើយសរសេរ URL : http://127.0.0.1/project/view_student.php
16. ជ្រើសរើស ការស្វែងរក ដោយឈ្មោះរបស់និស្សិត
ជ្រើស Search Fistname ហើយ សរសេរឈ្មោះរបស់និស្សិត ដែលអ្នកចង់ស្វែងរក
លទ្ធផល
17. ជ្រើសរើស ការស្វែងរក ដោយ មុខវិជ្ជារបស់និស្សិត
ជ្រើស Search major ហើយ សរសេរឈ្មោះមុខវិជ្ជារបស់និស្សិត ដែលអ្នកចង់ស្វែងរក
លទ្ធផល
18. ជ្រើសរើស ការស្វែងរក ដោយ វិទ្យាស្ថានសិក្សារបស់និស្សិត
ជ្រើស Search Institute ហើយ សរសេរឈ្មោះវិទ្យាស្ថានសិក្សារបស់និស្សិត ដែលអ្នកចង់ស្វែងរក
លទ្ធផល
សូមអរគុណសម្រាប់ការអានរបស់លោកអ្នក!
EmoticonEmoticon