|
|
|
คลิกเข้ากระทู้ หมายเลขลิ้งค์ก็ตรง แต่ทำไมข้อมูลในกระทู้ถึงไม่ตรงครับ |
|
|
|
|
|
|
|
ตามรูปอ่ะครับ ผมควรไปเช็คโค้ดในส่วนไหนดีครับ
น่าจะมีปัญหาในหน้าแสดงรายละเอียดกระทู้ นี่โค้ดครับ
Code (PHP)
<?php require_once('Connections/conn.php'); ?>
<?php require_once('Connections/conn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tbanswer (ADetail, AName, AEmail, ADate, RefQid) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ADetail'], "text"),
GetSQLValueString($_POST['AName'], "text"),
GetSQLValueString($_POST['AEmail'], "text"),
GetSQLValueString($_POST['ADate'], "date"),
GetSQLValueString($_POST['RefQid'], "int"));
mysql_select_db($database_conn, $conn);
$Result1 = mysql_query($insertSQL, $conn) or die(mysql_error());
$insertGoTo = "answer_save.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT Rtitle, Rname, Rphone, Ritem, Rtop, Raward, Rpic, Ruser, Rdate FROM tbreview";
$Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
$colname_Recordset2 = "-1";
if (isset($_GET['RecordID'])) {
$colname_Recordset2 = $_GET['RecordID'];
}
mysql_select_db($database_conn, $conn);
$query_Recordset2 = sprintf("SELECT ADetail, AName, AEmail, ADate, RefQid FROM tbanswer WHERE RefQid = %s", GetSQLValueString($colname_Recordset2, "int"));
$Recordset2 = mysql_query($query_Recordset2, $conn) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
?>
<html>
<table width="918" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" bgcolor="#66CC66"><h2><?php echo $row_Recordset1['Rtitle']; ?></h2></td>
<td width="395" bgcolor="#66CC66"> </td>
<td width="78" bgcolor="#66CC66"> </td>
<td width="164" bgcolor="#66CC66"> </td>
</tr>
<tr>
<td width="128" bgcolor="#66CC66"> </td>
<td width="131" align="right" bgcolor="#66CC66">ชื่อร้าน </td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Rtitle']; ?></td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66">เจ้าของร้าน </td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Rname']; ?></td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66">เบอร์โทรศัพท์ติดต่อ </td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Rphone']; ?></td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66">สินค้าโดดเด่น </td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Rtop']; ?></td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66">สินค้าที่ขาย </td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Ritem']; ?></td>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66"> </td>
<td colspan="2" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="right" bgcolor="#66CC66">รางวัลที่เคยได้รับ </td>
<td colspan="2" bgcolor="#66CC66"><?php echo $row_Recordset1['Raward']; ?></td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td colspan="2" bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td bgcolor="#66CC66"> </td>
<td colspan="2" align="center" valign="top" bgcolor="#66CC66"><?php echo $row_Recordset1['Rpic']; ?></td>
<td bgcolor="#66CC66"> </td>
</tr>
<tr>
<td bgcolor="#66CC66"> </td>
<td align="center" bgcolor="#66CC66">บทความโดย</td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Ruser']; ?></td>
<td align="center" bgcolor="#66CC66">บันทึกเมื่อ</td>
<td bgcolor="#66CC66"><?php echo $row_Recordset1['Rdate']; ?></td>
</tr>
</table>
<p> </p>
<table width="797" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="71" bgcolor="#66FFFF"> </td>
<td width="593" bgcolor="#66FFFF"><?php echo $row_Recordset2['ADetail']; ?></td>
<td width="394" bgcolor="#66FFFF"><h4> </h4></td>
</tr>
<tr>
<td align="right" bgcolor="#66FFFF"> </td>
<td colspan="2" align="right" bgcolor="#66FFFF">โดย :: <?php echo $row_Recordset2['AName']; ?> อีเมล์ :: <?php echo $row_Recordset2['AEmail']; ?>เมื่อ :: <?php echo $row_Recordset2['ADate']; ?></td>
</tr>
</table>
<p> </p>
<p> </p>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table width="641" align="center">
<tr valign="baseline">
<td height="131" align="right" valign="middle" nowrap>ความคิดเห็น</td>
<td><textarea name="ADetail" cols="60" rows="5" class="ckeditor"></textarea></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap>ชื่อ</td>
<td><input type="text" name="AName" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td align="right" valign="middle" nowrap>อีเมล์</td>
<td><input type="text" name="AEmail" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input name="btnSubmit" type="submit" id="btnSubmit" value="เพื่มข้อมูล"></td>
</tr>
</table>
<input type="hidden" name="ADate" value="<?=date("Y-m-d H:i:s");?>">
<input type="hidden" name="RefQid" value="<?php echo $row_Recordset1['Rid']; ?>">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
Tag : PHP, MySQL, HTML/CSS, CakePHP
|
|
|
|
|
|
Date :
2013-07-03 23:55:52 |
By :
benzsara |
View :
733 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จากรูปนะครับ คลิกที่ กระทู้ ทดสอบ 1 แต่เนื่้อหาดันเป็น ทดสอบ 2
และไม่ว่าจะตั้งกระทู้ใหม่มา เนื้อหาในหน้าแสดงรายละเอียดกระทู้ ก็จะเป็นของอันล่าสุดที่ได้กรอกข้อมูลลงไป
ช่วยหน่อยนะครับ ชี้แนะก็ได้
|
|
|
|
|
Date :
2013-07-03 23:58:10 |
By :
benzsara |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ช่วยหน่อยนะครับ
|
|
|
|
|
Date :
2013-07-04 10:19:54 |
By :
เบนซ์เล่นที่ม |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอนแรก
รับ RecordID มาใส่ colname_Recordset2
จากนั้นก็แปลงมาใส่ query_Recordset2
แล้วเอาค่าใส่ Recordset2
ตอนจบ echo row_Recordset1
มันมาได้ยังไง row_Recordset1
เขียนเองก็น่าจะรู้นะว่ามันเกิดจากอะไร
|
|
|
|
|
Date :
2013-07-04 14:45:08 |
By :
RootElement@KMUTNB |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|