สำหรับผู้ที่ เริ่มต้น Programming - PHP มีอะไร แนะนำ หรือข้อสงสัยต้องบอร์ด นี้ คนที่มีความรู้ แบ่งปันคนอื่นบ้างนะ ปัญหาการเขียนโปรแกรม แบบ OOP Session Cookies php network
Moderator: mindphp , ผู้ดูแลกระดาน
jetthoman555
โพสต์ที่ยังไม่ได้อ่าน
โดย jetthoman555 » 11/02/2010 9:06 am
ผมต้องการเปลี่ยนสถานะว่าคำถามนี้ตอบเเล้ว เเต่เขียนยังไงมันก็ไม่ไป update ที่ mysql ยังไงรบกวนช่วยเหลือด้วยครับ
contact_show.php
โค้ด: เลือกทั้งหมด
<?
session_start();
include("function.php");
$sess_aname=$_SESSION["aname"];
// ตรวจสอบ section ว่ามีค่ามาด้วยหรือไม่
if($sess_aname==''){
header( "Location: index.php?txt=l");
}
//echo $sess_id;
?>
<!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>
<link href="css_admin.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<?php include("header.html"); ?><br />
<?php include("menu.php"); ?><br /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table width="500" border="0" align="center" cellpadding="4" cellspacing="1" class="txt_detail_big">
<form action="conupdate.php" method="post" name="form_update">
<tr>
<td colspan="2" align="center">แสดงข้อความของผู้ติดต่อ</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<?
include ("../config.php");
//แสดงรายการ ที่มาติดต่อ
//$id = $_GET[id_n];
$sql="SELECT * FROM `contact` where c_id=$cid";
//echo sql;
$db->query($sql);
$row=$db->num_row();
while($o=mysql_fetch_object($db->result)){
?>
<tr>
<td width="80" height="16" align="right">ลำดับที่ :</td>
<td width="420" align="left"><? echo $o->c_id; ?></td>
</tr>
<tr>
<td align="right">ชื่อ :</td>
<td align="left"><? echo $o->c_name; ?></td>
</tr>
<tr>
<td align="right"><p>email :</p> </td>
<td align="left"><? echo $o->c_email; ?></td>
</tr>
<tr>
<td align="right">tel :</td>
<td align="left"><? echo $o->c_tel; ?></td>
</tr>
<tr>
<td align="right">หัวข้อ :</td>
<td align="left"><? echo $o->c_subject; ?></a></td>
</tr>
<tr>
<td align="right">ข้อความ :</td>
<td align="left"><? echo $o->c_message; ?></td>
</tr>
<tr>
<td align="right">ip :</td>
<td align="left"><? echo $o->c_ip; ?></td>
</tr>
<tr>
<td align="right">datetime :</td>
<td align="left"><? echo $o->c_datetime; ?></td>
</tr>
<tr bgcolor="#FFFFFF" class="text11">
<td height="25"><div align="right">Status : </div></td>
<td height="30"><span class="textBody">
<select name="consts" id="consts">
<option value="เลือกสถานะ"><- เลือกสถานะ -></option>
<option value="ยังไม่อ่าน"<? if($consts=="ยังไม่อ่าน"){?>selected<? }?>>ยังไม่ได้อ่าน </option>
<option value="อ่านแล้ว"<? if($consts=="อ่านแล้ว"){?>selected<? }?>>อ่านแล้ว </option>
<option value="ตอบแล้ว"<? if($consts=="ตอบแล้ว"){?>selected<? }?>>ตอบแล้ว </option>
<option value="ไม่ตอบ"<? if($consts=="ไม่ตอบ"){?>selected<? }?>>ไม่ตอบ </option>
</select>
<input name="id_n" type="hidden" id="consts" value='<?=$_REQUEST['cid'];?>'>
</span></td>
</tr>
<tr bgcolor="#FFFFFF" class="text11">
<td height="25"></td>
<td height="30"><input name="Submit4" type="submit" value="แก้ไขสถานะ" />
<input name="Submit23" type="submit" onclick="MM_goToURL('parent','contact_system.php');return document.MM_returnValue" value="ยกเลิกการแก้ไขสถานะ" /></td>
</tr>
<?
}//while
?>
</form>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<?php include("footer.html"); ?>
</body>
</html>
conupdate.php
โค้ด: เลือกทั้งหมด
<?
session_start();
include("function.php");
include ("../config.php");
$consts = $_REQUEST['consts'];
$cid = $_REQUEST['id_n'];
$sql = "update contact set consts='$consts' where c_id='$cid'";
$result = mysql_db_query($dbname, $sql);
header("Location: contact_show.php?cid=$id_n");
//header ("Location: contact_system.php");
//$sess_aname=$_SESSION["aname"];
//echo "<pre>" . print_r($_REQUEST[''],true) . "</pre>";
//echo mysql_error();
//$id = $_POST['id_n'];
//$cid = $_POST['c_id'];
/*include("connect_data.inc");
$q_date = date("Y-m-d H:i");
$q_ip = $_SERVER["REMOTE_ADDR"];
$getDateRegis= date('U');*/
//echo $sql="SELECT * FROM `contact` where c_id = $cid";
?>
ลอง echo sql ออกมาเเล้วได้
update contact set consts='อ่านแล้ว' where c_id='6'
Warning: Cannot modify header information - headers already sent by (output started at /home/machobiz/domains/the39cluesthailand.com/public_html/admin/conupdate.php:7) in /home/machobiz/domains/the39cluesthailand.com/public_html/admin/conupdate.php on line 9
เเต่ข้อมูลใน mysql ก็ยังไม่เปลี่ยนตามครับ ช่วยด้วยครับ
4404
โพสต์ที่ยังไม่ได้อ่าน
โดย 4404 » 11/02/2010 1:45 pm
jetthoman555 เขียน: ผมต้องการเปลี่ยนสถานะว่าคำถามนี้ตอบเเล้ว เเต่เขียนยังไงมันก็ไม่ไป update ที่ mysql ยังไงรบกวนช่วยเหลือด้วยครับ
contact_show.php
โค้ด: เลือกทั้งหมด
<?
session_start();
include("function.php");
$sess_aname=$_SESSION["aname"];
// ตรวจสอบ section ว่ามีค่ามาด้วยหรือไม่
if($sess_aname==''){
header( "Location: index.php?txt=l");
}
//echo $sess_id;
?>
<!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>
<link href="css_admin.css" rel="stylesheet" type="text/css" />
<script type="text/JavaScript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<?php include("header.html"); ?><br />
<?php include("menu.php"); ?><br /><br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<table width="500" border="0" align="center" cellpadding="4" cellspacing="1" class="txt_detail_big">
<form action="conupdate.php" method="post" name="form_update">
<tr>
<td colspan="2" align="center">แสดงข้อความของผู้ติดต่อ</td>
</tr>
<tr>
<td colspan="2" align="center"> </td>
</tr>
<?
include ("../config.php");
//แสดงรายการ ที่มาติดต่อ
//$id = $_GET[id_n];
$sql="SELECT * FROM `contact` where c_id=$cid";
//echo sql;
$db->query($sql);
$row=$db->num_row();
while($o=mysql_fetch_object($db->result)){
?>
<tr>
<td width="80" height="16" align="right">ลำดับที่ :</td>
<td width="420" align="left"><? echo $o->c_id; ?></td>
</tr>
<tr>
<td align="right">ชื่อ :</td>
<td align="left"><? echo $o->c_name; ?></td>
</tr>
<tr>
<td align="right"><p>email :</p> </td>
<td align="left"><? echo $o->c_email; ?></td>
</tr>
<tr>
<td align="right">tel :</td>
<td align="left"><? echo $o->c_tel; ?></td>
</tr>
<tr>
<td align="right">หัวข้อ :</td>
<td align="left"><? echo $o->c_subject; ?></a></td>
</tr>
<tr>
<td align="right">ข้อความ :</td>
<td align="left"><? echo $o->c_message; ?></td>
</tr>
<tr>
<td align="right">ip :</td>
<td align="left"><? echo $o->c_ip; ?></td>
</tr>
<tr>
<td align="right">datetime :</td>
<td align="left"><? echo $o->c_datetime; ?></td>
</tr>
<tr bgcolor="#FFFFFF" class="text11">
<td height="25"><div align="right">Status : </div></td>
<td height="30"><span class="textBody">
<select name="consts" id="consts">
<option value="เลือกสถานะ"><- เลือกสถานะ -></option>
<option value="ยังไม่อ่าน"<? if($consts=="ยังไม่อ่าน"){?>selected<? }?>>ยังไม่ได้อ่าน </option>
<option value="อ่านแล้ว"<? if($consts=="อ่านแล้ว"){?>selected<? }?>>อ่านแล้ว </option>
<option value="ตอบแล้ว"<? if($consts=="ตอบแล้ว"){?>selected<? }?>>ตอบแล้ว </option>
<option value="ไม่ตอบ"<? if($consts=="ไม่ตอบ"){?>selected<? }?>>ไม่ตอบ </option>
</select>
<input name="id_n" type="hidden" id="consts" value='<?=$_REQUEST['cid'];?>'>
</span></td>
</tr>
<tr bgcolor="#FFFFFF" class="text11">
<td height="25"></td>
<td height="30"><input name="Submit4" type="submit" value="แก้ไขสถานะ" />
<input name="Submit23" type="submit" onclick="MM_goToURL('parent','contact_system.php');return document.MM_returnValue" value="ยกเลิกการแก้ไขสถานะ" /></td>
</tr>
<?
}//while
?>
</form>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<?php include("footer.html"); ?>
</body>
</html>
conupdate.php
โค้ด: เลือกทั้งหมด
<?
session_start();
include("function.php");
include ("../config.php");
$consts = $_REQUEST['consts'];
$cid = $_REQUEST['id_n'];
$sql = "update contact set consts='$consts' where c_id='$cid'";
$result = mysql_db_query($dbname, $sql);
header("Location: contact_show.php?cid=$id_n");
//header ("Location: contact_system.php");
//$sess_aname=$_SESSION["aname"];
//echo "<pre>" . print_r($_REQUEST[''],true) . "</pre>";
//echo mysql_error();
//$id = $_POST['id_n'];
//$cid = $_POST['c_id'];
/*include("connect_data.inc");
$q_date = date("Y-m-d H:i");
$q_ip = $_SERVER["REMOTE_ADDR"];
$getDateRegis= date('U');*/
//echo $sql="SELECT * FROM `contact` where c_id = $cid";
?>
ลอง echo sql ออกมาเเล้วได้
update contact set consts='อ่านแล้ว' where c_id='6'
Warning: Cannot modify header information - headers already sent by (output started at /home/machobiz/domains/the39cluesthailand.com/public_html/admin/conupdate.php:7) in /home/machobiz/domains/the39cluesthailand.com/public_html/admin/conupdate.php on line 9
เเต่ข้อมูลใน mysql ก็ยังไม่เปลี่ยนตามครับ ช่วยด้วยครับ
mindphp
ผู้ดูแลระบบ MindPHP
โพสต์: 41245 ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:
โพสต์ที่ยังไม่ได้อ่าน
โดย mindphp » 11/02/2010 8:53 pm
ลอง copy คำสั่ง sql แล้วรันใน phpMyadmin ถ้าได้แสดงว่า
การติดต่อกับฐานข้อมูลยังไม่ได้
สาเหตุ อาจจะเรียกใช้ฐานข้อมูลชื่อที่กำหนดไม่ได้
สมาชิกกำลังดูบอร์ดนี้: Google [Bot] และบุคลทั่วไป 118