* Login   * Register


Last visit was:
It is currently Tue Dec 11, 2018 11:13 pm
View unanswered posts
View active topics





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: xóa_sửa sinh vien và xử lí
PostPosted: Tue Jun 02, 2009 11:56 pm 
Offline

Joined: Sun Feb 08, 2009 11:00 pm
Posts: 29
---------
XÓA SINH VIÊN

<?php
include("ketnoi.php");
?>
<?php
$sql="SELECT * from sinhvien where 'MaSV'='".$id."'";
$kq=mysql_query($sql,$link);
?>
<?php

if(mysql_num_rows($kq)!=0)
{
while($row=mysql_fetch_array($kq))
{
$id=$row["MaSV"];
$TenSV=$row["TenSV"];
$GioiTinh=$row["GioiTinh"];
$NamSinh=$row["NamSinh"];
$MaLop=$row["MaLop"];
$MaKhoa=$row["MaKhoa"];
$NoiSinh=$row["NoiSinh"];

}
}

?>
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="sinhvien" method="post" action="xlxoasv.php">

<div align="center">
<table width="400" height="109" border="0">
<tr>
<td height="43" colspan="2"><div align="center">B&#7841;n c&oacute; mu&#7889;n x&oacute;a sinh vi&ecirc;n n&agrave;y c&oacute; kh&ocirc;ng? </div></td>
</tr>
<tr>
<td width="109">&nbsp;</td>
<td width="281"><label>
<input type="hidden" name="id" value="<?=$id?>">
<input type="submit" name="Submit" value="X&oacute;a" />
<input type="button" name="Submit2" value="Kh&ocirc;ng" onClick="history.go(-1)"/>

</label></td>
</tr>
</table>
</div>
</form>
</body>
</html>

XỬ LÍ XÓA

<?php
require("ketnoi.php");
$sql="delete from sinhvien where MaSV='$id'";
$kq=mysql_query($sql,$link);

if($kq)
{
echo"<script> alert('Xoa thanh cong');</script>";
}
else
{
echo"<script> alert('Xoa khong thanh cong, Xin vui long thu lai');</script>";
}
echo'<meta http-equiv="REFRESH" content="0;URL=themsv.php"/>';
?>












SỬA SV

<?php
include("ketnoi.php");
?>
<?php
$sql="SELECT * from sinhvien where MaSV=\"$id\"";
$kq=mysql_query($sql,$link);
?>
<?php
if(mysql_num_rows($kq)!=0)
{
while($row=mysql_fetch_array($kq))
{
$id=$row["MaSV"];
$TenSV=$row["TenSV"];
$GioiTinh=$row["GioiTinh"];
$NamSinh=$row["NamSinh"];
$MaLop=$row["MaLop"];
$MaKhoa=$row["MaKhoa"];
$NoiSinh=$row["NoiSinh"];
}
}

?>
<!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=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {
font-size: 24px;
color: #3366CC;
font-weight: bold;
}
.style10 {color: #3366CC; font-size: 16px; font-weight: bold; }
-->
</style>
</head>

<body>
<form id="form1" name="sinhvien" method="post" action="xlsuasv.php" onsubmit="return kiemtra();">
<script language="javascript">
function kiemtra()
{
if(document.sinhvien.txtMaSV.value=='')
{
alert("vui long nhap vao ma sinh vien ");
document.sinhvien.txtMaSV.focus();
return false;
}
return true;
if(document.sinhvien.txtTenSV.value=='')
{
alert("vui long nhap vao ten sinh vien ");
document.sinhvien.txtTenSV.focus();
return false;
}
return true;
if(document.sinhvien.txtGioiTinh.value=='')
{
alert("vui long nhap vao gioi tinh ");
document.sinhvien.txtGioiTinh.focus();
return false;
}
return true;
if(document.sinhvien.txtNamSinh.value=='')
{
alert("vui long nhap vao nam sinh cua sinh vien ");
document.sinhvien.txtNamSinh.focus();
return false;
}
return true;
if(document.sinhvien.txtMaLop.value=='')
{
alert("vui long nhap vao ma lop");
document.sinhvien.txtMaLop.focus();
return false;
}
return true;
if(document.sinhvien.txtMaKhoa.value=='')
{
alert("vui long nhap vao ma khoa ");
document.sinhvien.txtMaKhoa.focus();
return false;
}
return true;
if(document.sinhvien.txtNoiSinh.value=='')
{
alert("vui long nhap vao noi sinh cua sinh vien ");
document.sinhvien.txtNoiSinh.focus();
return false;
}
return true;
}
</script>
<div align="center">
<table width="584" height="529" border="0">
<tr>
<td colspan="2"><div align="center" class="style1">C&#7852;P NH&#7852;T TH&Ocirc;NG TIN SINH VI&Ecirc;N</div></td>
</tr>
<tr>
<td width="138" height="64"><span class="style10">M&atilde; Sinh Vi&ecirc;n:</span></td>
<td width="430"><label>
<input name="txtMaSV" type="text" id="txtMaSV" size="45" value="<?=$id?>" />
</label></td>
</tr>
<tr>
<td height="58"><span class="style10">T&ecirc;n Sinh Vi&ecirc;n: </span></td>
<td><label>
<input name="txtTenSV" type="text" id="txtTenSV" size="45" value="<?=$TenSV?>"/>
</label></td>
</tr>
<tr>
<td height="66"><span class="style10">Gi&#7899;i T&iacute;nh: </span></td>
<td><label>
<input name="txtGioiTinh" type="text" id="txtGioiTinh" value="<?=$GioiTinh?>" size="45" />
</label></td>
</tr>
<tr>
<td height="66"><span class="style10">N&#259;m Sinh: </span></td>
<td><label>
<input name="txtNamSinh" type="text" id="txtNamSinh" value="<?=$NamSinh?>" size="45" />
</label></td>
</tr>
<tr>
<td height="66"><span class="style10">M&atilde; L&#7899;p: </span></td>
<td><label>
<input name="txtMaLop" type="text" id="txtMaLop" value="<?=$MaLop?>" size="45" />
</label></td>
</tr>
<tr>
<td height="66"><span class="style10">M&atilde; Khoa: </span></td>
<td><label>
<input name="txtMaKhoa" type="text" id="txtMaKhoa" value="<?=$MaKhoa?>" size="45" />
</label></td>
</tr>
<tr>
<td height="66"><span class="style10">N&#417;i Sinh: </span></td>
<td><label>
<input name="txtNoiSinh" type="text" id="txtNoiSinh" value="<?=$NoiSinh?>" size="45" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="hidden" name="id" value="<?=$id?>">
<input name="Submit" type="submit" class="style10" value="Update" />
<input name="Submit2" type="button" class="style10" value="Cancel" onClick="history.go(-1)"/>
</label></td>
</tr>
</table>
</div>
</form>
</body>
</html>

XỬ LÍ SỬA
<?php
include('ketnoi.php');
$sql="update sinhvien set MaSV='$txtMaSV',TenSV='$txtTenSV',GioiTinh='$txtGioiTinh',NamSinh='$txtNamSinh',MaLop='$txtMaLop',MaKhoa='$txtMaKhoa',NoiSinh='$txtNoiSinh' where MaSV='$id'";
$kq=mysql_query($sql,$link);

if($kq)
{
echo"<script> alert('Cap nhat thanh cong');</script>";
}
else
{
echo"<script> alert('Cap nhat khong thanh cong, Xin vui long thu lai');</script>";
}
echo'<meta http-equiv="REFRESH" content="0;URL=themsv.php"/>';
mysql_close($link);
?>


Report this post
Top
 Profile E-mail  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron

Free Forum · php-BB© · Internationalization Project · Report abuse · Terms Of Use/Privacy Policy
© Forums-Free.com 2009