ติดปัญหาตรง เพิ่ม(มันไม่แสดงข้อมูลของรายละเอียด) และ แก้ไข ค่ะ
ถาม-ตอบ แนะนำไอเดียว โค้ดตัวอย่าง แนวทาง วิธีแก้ปัญหา ติดปัญหาตรง เพิ่ม(มันไม่แสดงข้อมูลของรายละเอียด) และ แก้ไข ค่ะ
ติดปัญหาตรง เพิ่ม(มันไม่แสดงข้อมูลของรายละเอียด) และ แก้ไข ค่ะ
Copy
//หน้าโชว์ข้อมูล
//หน้าเพิ่มข้อมูล
//หน้าแก้ไขข้อมูลupdate
<?php
session_start();
include("db/connect.php");//เรียกใช้ไฟล์connect.php
error_reporting (E_ALL ^ E_NOTICE); //ดัก noticeออกไป
if($_GET['do']=="delete")//เข้าเงื่อนไข $_GET (คือการที่เพิ่มข้อมูลมากแต่ต้องมาพร้อมกับฟอร์ม)โดยใช้กับปุ่มdelete
{
$sid = $_GET['sid'];
$a = "DELETE from doc_company where d_name = '$sid'";
$query = mysql_query($a)or die(mysql_error());
echo "<script type='text/javascript'>alert('ลบข้อมูลเรียบร้อยแล้ว')</script>";
echo "<meta http-equiv ='refresh'content='0;URL=Untitled-1.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>
<form action = "Untitled-1.php" method = "post" >
<table align="center"><tr><td>ค้นหารายละเอียดเอกสาร :
<input type="text" name="search" id="search" value="<? echo $com_description; ?>" ; />
<input name="find" type="submit" id="find" value="ค้นหา" /></center></td></tr></div></table>
<br />
<table width="100%"><tr>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> </td>
<td width="25%"> [ <a href="Untitled-2.php"> เพิ่มเอกสาร</a> ]</td></tr>
</table>
</form>
<table border="2" cellspacing="0" cellpadding="2" align="center" width="70%">
<tr>
<th bgcolor="#FFFF33" width="15%" >ชื่อเอกสาร/งวดที่</th>
<th bgcolor="#FFFF33" width="8%">วันที่</th>
<th bgcolor="#FFFF33" width="15%" >ไฟล์เอกสาร</th>
<th bgcolor="#FFFF33" width="15%" >รายละเอียด</th>
<th bgcolor="#FFFF33" width="8%">แก้ไข l ลบ</th>
</tr>
<?php
$strQuery = "SELECT * FROM doc_company";
if(isset($_POST['search']) )
{
$strQuery = $strQuery . " WHERE com_description LIKE '%". $_POST['search']. "%' ";
}
$strQuery = $strQuery . ";";
//echo $strQuery . "</br>";
$check_log = mysql_query($strQuery) or die (mysql_error());
$num = mysql_num_rows($check_log);
if($num <=0) {
}
$n=0;//ให้ค่า n= 0
while ($objResult = mysql_fetch_array($check_log)){
?>
<tr>
<td align="center"><?=$objResult[num] ?> <?=$objResult[d_name] ?></td>
<td align="center"><?=$objResult[date_com_up] ?></td>
<td align="center"><?=$objResult[com_file] ?></td>
<td align="center"><?=$objResult[com_description ] ?></td>
<td align="center">
<a href="Untitled-3.php?do=edit&sid=<?php echo $objResult["d_name"]; ?>">แก้ไข</a>
|
<a href="Untitled-1?do=delete&sid=<?php echo $objResult['d_name']; ?> ">ลบ</a></td>
</tr>
<?php }?>
</table></td>
</tr>
</table>
</body>
</html>
//หน้าเพิ่มข้อมูล
<?php
session_start();
include("db/connect.php");//เรียกใช้ไฟล์connect.php
error_reporting (E_ALL ^ E_NOTICE); //ดัก noticeออกไป
if($_POST["Save"]){
$str=" insert into `doc_company`
( `d_name`,`num`,`com_file`,`date_com_up`,`com_description`,`p_id`)
values ( '$d_name' , '$num' , '$com_file' , '$date_com_up', '$com_description', '$p_id') " ;
mysql_query($str) or die (mysql_error());
echo "<script type='text/javascript'>alert('บันทึกข้อมูลเรียบร้อยแล้ว')</script>";
echo "<meta http-equiv ='refresh'content='0;URL=Untitled-1.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>
<form name="form1" method="post">
<table align="center" width="28%">
<tr>
<th colspan="2" align="center" bgcolor="#FFFF99" scope="col" >เพิ่มเอกสารบริษัท</th>
</tr>
<tr>
<td align="right">โปรเจค : </td>
<td>
<label for="p_id"></label>
<select name="p_id" id="p_id">
<option selected="selected">--กรุณาเลือก--</option>
<option value="1">MA Fiber</option>
<option value="2">MA Equipment</option>
</select> <font color="#FF0000">*</font></td></tr>
<tr>
<td width="45%" align="right">วันที่อัพเอกสาร :</td>
<td ><label for="date_com_up"></label>
<input type="date" name="date_com_up" id="date_com_up" ; />
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td width="45%" align="right">ชื่อเอกสารบริษัท :</td>
<td ><label for="d_name"></label>
<input type="text" name="d_name" id="d_name" />
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td align="right">งวดที่ :</td>
<td ><label for="num"></label>
<input type="text" name="num" id="num" />
<font color="#FF0000">* งวดที่1</font></td>
</tr>
<tr>
<td width="45%" align="right">รายละเอียด :</td>
<td ><label for="com_description"></label>
<input type="text" name="com_description" id="com_description"/>
<font color="#FF0000">*</font></td>
</tr>
<tr>
<th colspan="2" align="center" bgcolor="#FFFF99" scope="col" >เอกสารบริษัท</th>
</tr>
<tr bgcolor="#FFFFCC">
<td width="132" align="right">งวดที่_1 </td>
<td><input type="file" name="com_file"></td>
</tr>
<tr bgcolor="#FFFFCC">
<td align="right">งวดที่_2 </td>
<td><input type="file" name="com_file"></td>
</table>
<p align="center">
<input type="submit" name="Save" id="Save" value="บันทึก" />
<input type="reset" name="cancel" id="cancel" value="ยกเลิก" />
</p>
</table></form>
</body>
</html>
//หน้าแก้ไขข้อมูลupdate
<?php
session_start();
include("db/connect.php");//เรียกใช้ไฟล์connect.php
error_reporting (E_ALL ^ E_NOTICE); //ดัก noticeออกไป
if($_POST["Save"]){
//$core_id=$_POST["core_id"];
$zone_core=$_POST['d_name'];
$core_name=$_POST['num'];
$file_core=$_POST['com_file'];
$date_core_up=$_POST['date_com_up'];
$core_description=$_POST['com_description'];
$p_id=$_POST["p_id"];
$sid=$_POST["sid"];
$sql = "UPDATE doc_company SET d_name='$d_name',num='$num',com_file='$com_file',date_com_up='$date_com_up',com_description='$com_description',p_id='$p_id' WHERE d_name ='$sid'";
$query = mysql_query($sql) or die (mysql_error());
echo "<script type='text/javascript'>alert('บันทึกข้อมูลเรียบร้อยแล้ว')</script>";
echo "<meta http-equiv ='refresh'content='0;URL=Untitled-1.php'>";
}
if($_GET['do']=="edit") //เป็นการคำสั่งในแก้ไขข้อมูล
{
$sid = $_GET['sid'];
$sql = "select * from doc_company where d_name = '$sid'";
$a = mysql_query($sql) or die (mysql_error());
$objResult = mysql_fetch_array($a);
}
?>
<!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>
<table align="center">
<tr>
<th colspan="2" align="center" bgcolor="#FFFF99" scope="col" >เพิ่มเอกสารบริษัท</th>
</tr>
<tr>
<td align="right">โปรเจค : </td>
<td> <label for="p_id"></label>
<select name="p_id" id="p_id">
<option selected="selected">--กรุณาเลือก--</option>
<option value="1">MA Fiber</option>
<option value="2">MA Equipment</option>
</select><font color="#FF0000"> *</font></td></tr>
<tr>
<td width="45%" align="right">วันที่อัพเอกสาร :</td>
<td ><label for="date_com_up"></label>
<input type="date" name="date_com_up" id="date_com_up" value="<?php echo $objResult['date_com_up'] ?>" />
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td align="right">ชื่อเอกสารบริษัท :</td>
<td ><label for="d_name"></label>
<input type="text" name="d_name" id="d_name" value="<?php echo $objResult['d_name'] ?>" />
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td height="28" align="right">งวดที่ :</td>
<td ><label for="num"></label>
<input type="text" name="num" id="num" value="<?php echo $objResult['num'] ?>" />
<font color="#FF0000">* งดวที่1</font></td>
</tr>
<tr>
<td height="28" align="right">รายละเอียด :</td>
<td ><label for="com_description"></label>
<input type="text" name="com_description" id="com_description" value="<?php echo $objResult['com_description'] ?>" />
<font color="#FF0000">*</font></td>
</tr>
<tr>
<th colspan="2" align="center" bgcolor="#FFFF99" scope="col" >เอกสารงวด</th>
<tr>
<tr bgcolor="#FFFFCC">
<td align="right"><div align="center">งวดที่1 </div></td>
<td><div align="center">
<input type="file" name="QDatafile1" size=20>
</div></td></tr>
<tr bgcolor="#FFFFCC">
<td align="right"><div align="center">งวดที่2 </div></td>
<td><div align="center">
<input type="file" name="QDatafile2" size=20>
</div></td>
</tr>
</table>
<p align="center">
<input name="sid" type="hidden" value="<?php echo $sid;?>" />
<input type="submit" name="Save" id="Save" value="บันทึก" />
<input type="reset" name="cancel" id="cancel" value="ยกเลิก" />
</p>
</body>
</html>
คำแนะนำ และการใช้งาน
สมาชิก กรุณา ล็อกอินเข้าระบบ เพื่อตั้งคำถามใหม่ หรือ ตอบคำถาม สมาชิกใหม่ สมัครสมาชิกได้ที่ สมัครสมาชิก
- ถาม-ตอบ กรุณา ล็อกอินเข้าระบบ
เว็บไซต์ของเราให้บริการเนื้อหาบทความสำหรับนักพัฒนา โดยพึ่งพารายได้เล็กน้อยจากการแสดงโฆษณา
โปรดสนับสนุนเว็บไซต์ของเราด้วยการปิดการใช้งานตัวปิดกั้นโฆษณา (Disable Ads Blocker) ขอบคุณครับ