|
|
|
PHP - ช่วยดู WebBoard ให้ผมหน่อยนะครับ ตรง View WebBoard ทีหลังทำไมมันขึ้นไปเป็นความคิดเห็นที่ 1 |
|
|
|
|
|
|
|
ต้องใช้ order by asc
ครับ
|
|
|
|
|
Date :
2013-09-15 15:57:39 |
By :
iieszz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQL ORDER BY
|
|
|
|
|
Date :
2013-09-15 16:31:55 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใส่ตรงไหนครับCode (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("mechanical_engineering");
if($_GET["Action"] == "Save")
{
//*** Insert Reply ***//
$strSQL = "INSERT INTO reply ";
$strSQL .="(QuestionID,CreateDate,Details,Name) ";
$strSQL .="VALUES ";
$strSQL .="('".$_GET["QuestionID"]."','".date("Y-m-d H:i:s")."','".$_POST["txtDetails"]."','".$_POST["txtName"]."') ";
$objQuery = mysql_query($strSQL);
//*** Update Reply ***//
$strSQL = "UPDATE webboard ";
$strSQL .="SET Reply = Reply + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL);
}
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>webbord</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #006633;
}
.style1 {color: #000000}
-->
</style></head>
<body><center>
<?
//*** Select Question ***//
$strSQL = "SELECT * FROM webboard WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
//*** Update View ***//
$strSQL = "UPDATE webboard ";
$strSQL .="SET View = View + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL);
?>
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td colspan="2"><center><h1><?=$objResult["Question"];?></h1></center></td>
</tr>
<tr>
<td height="53" colspan="2"><?=nl2br($objResult["Details"]);?></td>
</tr>
<tr>
<td width="397">Name : <?=$objResult["Name"];?> Create Date : <?=$objResult["CreateDate"];?></td>
<td width="253">View : <?=$objResult["View"];?> Reply : <?=$objResult["Reply"];?></td>
</tr>
</table>
<br>
<br>
<?
$intRows = 0;
$strSQL2 = "SELECT * FROM reply WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
$intRows++;
?>
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td height="53" colspan="2"><p>ความคิดเห็นที่ :
<?=$intRows;?>
</p>
<?=nl2br($objResult2["Details"]);?></td>
</tr>
<tr>
<td width="397">โดย :
<?=$objResult2["Name"];?> </td>
<td width="253">Create Date :
<?=$objResult2["CreateDate"];?></td>
</tr>
</table>
<br>
<?
}
?>
<br>
<a href="Webboard.php" class="style1">กลับสู่เว็บบอร์ด</a> <br>
<br>
<form action="ViewWebboard.php?QuestionID=<?=$_GET["QuestionID"];?>&Action=Save" method="post" name="frmMain" id="frmMain">
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td width="78">ความเห็น</td>
<td><textarea name="txtDetails" cols="50" rows="8" id="txtDetails"></textarea></td>
</tr>
<tr>
<td width="78">โดย</td>
<td width="647"><input name="txtName" type="text" id="txtName" value="" size="50"></td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="ยืนยัน">
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
|
|
|
|
|
Date :
2013-09-15 16:35:27 |
By :
mos0810425036 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$strSQL2 = "SELECT * FROM reply WHERE QuestionID = '".$_GET["QuestionID"]."' ORDER BY id";
บรรทัด 61
ทำไม ใช้ questionid เป็น string ล่ะ
|
|
|
|
|
Date :
2013-09-15 19:28:17 |
By :
pjgunner.com |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมใช้โคด https://www.thaicreate.com/free-web-script/php-create-webboard-mysql.html นี้คับ
พอใส่แล้วมัน Error คับ
Code (PHP)
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("mechanical_engineering");
if($_GET["Action"] == "Save")
{
//*** Insert Reply ***//
$strSQL = "INSERT INTO reply ";
$strSQL .="(QuestionID,CreateDate,Details,Name) ";
$strSQL .="VALUES ";
$strSQL .="('".$_GET["QuestionID"]."','".date("Y-m-d H:i:s")."','".$_POST["txtDetails"]."','".$_POST["txtName"]."') ";
$objQuery = mysql_query($strSQL);
//*** Update Reply ***//
$strSQL = "UPDATE webboard ";
$strSQL .="SET Reply = Reply + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL);
}
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<title>webbord</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
background-color: #006633;
}
.style1 {color: #000000}
-->
</style></head>
<body><center>
<?
//*** Select Question ***//
$strSQL = "SELECT * FROM webboard WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$objResult = mysql_fetch_array($objQuery);
//*** Update View ***//
$strSQL = "UPDATE webboard ";
$strSQL .="SET View = View + 1 WHERE QuestionID = '".$_GET["QuestionID"]."' ";
$objQuery = mysql_query($strSQL);
?>
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td colspan="2"><center><h1><?=$objResult["Question"];?></h1></center></td>
</tr>
<tr>
<td height="53" colspan="2"><?=nl2br($objResult["Details"]);?></td>
</tr>
<tr>
<td width="397">Name : <?=$objResult["Name"];?> Create Date : <?=$objResult["CreateDate"];?></td>
<td width="253">View : <?=$objResult["View"];?> Reply : <?=$objResult["Reply"];?></td>
</tr>
</table>
<br>
<br>
<?
$intRows = 0;
$strSQL2 = "SELECT * FROM reply WHERE QuestionID = '".$_GET["QuestionID"]."' ORDER BY id";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL."]");
while($objResult2 = mysql_fetch_array($objQuery2))
{
$intRows++;
?>
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td height="53" colspan="2"><p>ความคิดเห็นที่ :
<?=$intRows;?>
</p>
<?=nl2br($objResult2["Details"]);?></td>
</tr>
<tr>
<td width="397">โดย :
<?=$objResult2["Name"];?> </td>
<td width="253">Date :
<?=$objResult2["CreateDate"];?></td>
</tr>
</table>
<br>
<?
}
?>
<br>
<a href="Webboard.php" class="style1">กลับสู่เว็บบอร์ด</a> <br>
<br>
<form action="ViewWebboard.php?QuestionID=<?=$_GET["QuestionID"];?>&Action=Save" method="post" name="frmMain" id="frmMain">
<table width="738" border="1" cellpadding="1" cellspacing="1" bgcolor="#006666">
<tr>
<td width="78">ความเห็น</td>
<td><textarea name="txtDetails" cols="50" rows="8" id="txtDetails"></textarea></td>
</tr>
<tr>
<td width="78">โดย</td>
<td width="647"><input name="txtName" type="text" id="txtName" value="" size="50"></td>
</tr>
</table>
<input name="btnSave" type="submit" id="btnSave" value="ยืนยัน">
</form>
</body>
</html>
<?
mysql_close($objConnect);
?>
ขอบคุณครับ
|
|
|
|
|
Date :
2013-09-15 21:40:09 |
By :
mos0810425036 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับขอบคุณครับ ใส่ ReplyID หลัง order by
|
|
|
|
|
Date :
2013-09-15 22:54:29 |
By :
mos0810425036 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-09-16 08:54:49 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|