|
|
|
รบกวนช่วยดูโค้ดให้หน่อยครับ ถ้าเราจะเพิ่มข้อมูลสมาชิกโดยมีการเก็บรูปภาพด้วย ซึ่งเก็บไว้ในฐานข้อมูล |
|
|
|
|
|
|
|
<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
include("chk_login.php");
include("menu.php") ;
?>
<h3>ค้นหาข้อมูล</h3>
<form id="form1" name="form1" method="post" action="">
<label>คำค้น
<input type="text" name="inKeyword" id="inKeyword" />
</label>
<label>
<input type="submit" name="Submit" id="Submit" value=" ค้นหา " />
</label>
</form><hr />
<?php
if(isset($_POST[inKeyword])) {
include("config.php") ; //require
$key = $_POST[inKeyword] ;
$sql = "select * from student as s, faculty as f where s.f_id=f.fid and (s.id like '%$key%' or s.name like '%$key%')" ;
$result = mysql_query($sql) ;
$count = mysql_num_rows($result) ;
echo "<b><u>ค้นพบ $count รายการ</u></b><br />" ;
while($data = mysql_fetch_array($result)) {
echo "$data[id] <br />" ;
echo "$data[name] <br />" ;
echo "$data[address] <br />" ;
echo "$data[gpa] <br />" ;
echo "$data[fname] <br />" ;
echo "$data[phone] <br />" ;
echo "$data[email] <hr />" ;
}
mysql_close($conn) ;
}
?>
</body>
</html>
-------------------------------------------------------------------------------------------------------------------------------------
<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" src="../50010912223/Ch21/checkform.js"></script>
</head>
<body>
<?php
include("chk_login.php");
include("menu.php") ;
include("config.php");
$sql3="select *from student where id='$_GET[sid]'";
$result3=mysql_query($sql3);
$data3=mysql_fetch_array($result3);
?>
<h3>แก้ไข</h3>
<form name="frmAdd" method="post" action="" onSubmit="return chk_add();">
<table width="372" border="0" cellspacing="1" cellpadding="1">
<tr>
<td width="89" bgcolor="#C9B4D3">รหัสนิสิต</td>
<td width="276" bgcolor="#EBE2EF"><input type="text" name="inID" id="inID" value="<?=$data3[id];?>"></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">ชื่อ-สกุล</td>
<td bgcolor="#EBE2EF"><input type="text" name="inName" id="inName" value="<?=$data3[name];?>"></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">ที่อยู่</td>
<td bgcolor="#EBE2EF"><textarea name="inAddress" id="inAddress" cols="30" rows="4"><?=$data3[address];?></textarea></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">เกรดเฉลี่ย</td>
<td bgcolor="#EBE2EF"><input type="text" name="inGpa" id="inGpa" value="<?=$data3[gpa];?>"></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">คณะ</td>
<td bgcolor="#EBE2EF"><select name="inFac" id="inFac">
<option value=""> - - - - - เลือก - - - - - </option>
<?php
include("config.php"); // = สีแดง ใช้แสดงคาสPHP
$sql = "select * from faculty" ;
$result = mysql_query($sql) ;
while ($data = mysql_fetch_array($result)) {
if($data[fid] ==$data3[f_id]){
$s="selected";
}else{
$s="";
}
echo "<option value='$data[fid]'$s> $data[fname] </option>" ;
}
?>
</select></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">เบอร์โทร</td>
<td bgcolor="#EBE2EF"><input type="text" name="inPhone" id="inPhone" value="<?=$data3[phone];?>"></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">อีเมล์</td>
<td bgcolor="#EBE2EF"><input type="text" name="inEmail" id="inEmail" value="<?=$data3[email];?>"></td>
</tr>
<tr>
<td bgcolor="#C9B4D3">รูปภาพ</td>
<td bgcolor="#EBE2EF"><label>
<input name="inFile" type="file" id="inFile">
</label></td>
</tr>
<tr>
<td bgcolor="#C9B4D3"><input type="hidden" name="inID2" value="<?=$_GET[sid];?>"></td>
<td bgcolor="#EBE2EF"><label>
<input type="submit" name="Submit" id="Submit" value=" บันทึกข้อมูล ">
<input type="reset" name="Reset" id="button" value="Reset">
</label></td>
</tr>
</table>
</form>
</body>
<?php
if(isset($_POST[Submit])) {
$sql2 = "update student set id='$_POST[inID]', name='$_POST[inName]',address='$_POST[inAddress]',gpa='$_POST[inGpa]', f_id='$_POST[inFac]',phone='$_POST[inPhone]',email='$_POST[inEmail]','$_POST[inFile]' where id='$_POST[inID2]'" ;
//var_dump($sql2) ; exit ;
mysql_query($sql2) or die ("แก้ไขข้อมูลไม่ได้");
echo "แก้ไขข้อมูลเรียบร้อยแล้ว" ;
echo "<meta http-equiv=refresh content=3;url=showStudent.php />" ;
}
?>
</html>
|
|
|
|
|
Date :
2009-11-08 21:21:20 |
By :
tsuyosai_kingdom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|