|
|
|
เว็บบอร์ดใช้งานไม่ได้ครับ กดตั้งกระทู้แล้วไม่แสดงตรงหัวข้อกระทู้ทำให้คลิกเข้าไปตอบกลับไม่ได้ครับ PHP +SQL |
|
|
|
|
|
|
|
นี้เป็นหน้าหลักเว็บบอร์ดครับ
Code (PHP)
<? session_start(); ?>
<?php
$id_post=$_SESSION['id'];
$name_post=$_SESSION['nickname'];
if (!isset ($_SESSION['user']) ) {
echo "<script language='javascript'>alert('ไม่สามารถเข้าในส่วนนี้ได้!!!');history.back();</script> ";
echo "<meta http-equiv='refresh' content='1 ; url=main.html' />";
exit () ;
}
?>
<!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>KP Photo</title>
<meta name="Keywords" content="Christmas Night, free css, templates, flash slider, HTML" />
<meta name="Description" content="Christmas Night - free CSS template provided by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "templatemo_menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
flashvars.xml_file = "photo_list.xml";
var params = {};
params.wmode = "transparent";
var attributes = {};
attributes.id = "slider";
swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "900", "290", "9.0.0", false, flashvars, params, attributes);
</script>
<style type="text/css">
#apDiv1 {
position:absolute;
left:166px;
top:213px;
width:845px;
height:277px;
z-index:1;
font-size: 13px;
}
a:link {
color: #F00;
}
a:visited {
color: #00F;
}
body,td,th {
color: #000;
}
</style>
</head>
<body>
<div id="apDiv1">
<center>
<img src="images/zzz.gif" alt="" width="254" height="43" />
</center>
<br />
<?
print "<table width=532 border=1 align=center cellpadding=1 cellspacing=1
bordercolor=0000FF>";
print "<tr>";
print"<td width=703>";
print"<table width=532 align=center>";
print"<tr bgcolor=003399>";
print"<td align=center><font color=FF6600><b>รหัสกระทู้</b></font></td>";
print"<td align=center><font color=FF6600><b>หัวข้อกระทู้</b></font></td>";
print"<td align=center><font color=FF6600><b>ผู้ตั้งคำถาม</b></font></td>";
print"<td align=center><font color=FF6600><b>วันที่ตั้งคำถาม</b></font></td>";
print"</tr>";
include('config.inc.php');
mysql_select_db($dbname) or die("ไม่สามารถเลือกฐานข้อมูลได้");
mysql_query("SET NAMES UTF8");
$sql = "select * from quiz order by id_quiz desc";
$dbquery = mysql_db_query($dbname, $sql);
// หาจำนวนเรกคอร์ดข้อมูลในตาราง
$num_rows = mysql_num_rows($dbquery);
// เริ่มวนรอบแสดงข้อมูล
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$id_quiz = $result[id_quiz];
$title = $result[title];
$name = $result[name];
$message = $result[message];
$email = $result[email];
$date_q = $result[date_q];
$count_q = $result[count_q];
print"<tr bgcolor=CCCCCC>";
print"<td>".$id_quiz."</td>";
print"<td><A HREF=\"show_ans.php?id_quiz=$id_quiz\"
target=\"$id_question\">$title</a></td>";
print"<td>".$name."</td>";
print"<td>".$date_q."</td>";
print"</tr>";
$i++;}
print"</table>";
mysql_close();
print"</td>";
print"</tr>";
print"</table>";
?>
<form action="post_q.php" method="post" name="form1" id="form1">
<table width="532" border="1" align="center" cellpadding="1" cellspacing="1" bordercolor="0000ff">
<tr>
<td width="703"><table width="524" align="center" cellspacing="1">
<tr>
<td colspan="2" bgcolor="#FFFFFF"><div align="center"><u>ตั้งกระทู้ใหม่</u></div></td>
</tr>
<tr>
<td width="97" bgcolor="#CCCCCC">หัวข้อกระทู้</td>
<td width="417" bgcolor="#999999"><input name="title" type="text" id="title" size="65" /></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">รายละเอียด</td>
<td bgcolor="#999999"><textarea name="message" cols="65" rows="7" wrap="virtual" id="message"></textarea></td>
</tr>
<tr>
<td bgcolor="#CCCCCC">ชื่อผู้โพสต์</td>
<td bgcolor="#999999"><? echo $name_post ?> </td>
</tr>
<tr>
<td bgcolor="#CCCCCC">รหัสสมาชิก</td>
<td bgcolor="#999999"><? echo $id_post ?> </td>
</tr>
<tr>
<td bgcolor="#cccccc"></td>
<td bgcolor="#999999"><input type="submit" name="Submit" value="ตั้งคำถาม" />
<input type="reset"name="submit2" value="ยกเลิก" /></td>
</tr>
</table></td>
</tr>
</table>
</form>
</div>
<div id="templatemo_wrapper_outter">
<div id="templatemo_wrapper_inner">
<div id="templatemo_wrapper">
<div id="templatemo_menu" class="ddsmoothmenu">
<ul>
<li><a href="main.html" class="selected">หน้าหลัก</a></li>
<li><a href="head.html" target="topFrame">สมาชิก</a>
<ul>
<li><a href="member_upload.php">Upload Image</a></li>
<li><a href="member_showimage.php">Image All</a></li>
<li><a href="member_update.php">Edit Proflies</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</li>
<li><a href="#">ผู้ดูแลระบบ</a>
<ul>
<li>
</ul>
</li>
<li><a href="formregister.php">ลงทะเบียน</a></li>
<li><a href="about.html">เกี่ยวกับ</a></li>
<li><a href="contact.php">เว็บบอร์ด</a></li>
</ul>
<br style="clear: left" />
</div><!-- end of templatemo_menu -->
<div id="templatemo_header">
<div id="site_title"><h1><a href="main.html">Free CSS Templates</a></h1></div>
</div> <!-- end of header -->
<div id="templatemo_main_top"></div>
<div class="cleaner"></div>
</div>
</div>
</body>
</html>
นี้เป็นไฟล์ show_ansครับ
Code (PHP)
<? session_start(); ?>
<?php
$id_post=$_SESSION['id'];
$name_post=$_SESSION['nickname'];
if (!isset ($_SESSION['user'])) {
echo "<meta http-equiv='refresh' content='1 ; url=main.html' />";
exit () ;
}
?>
<!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>KP Photo</title>
<meta name="Keywords" content="Christmas Night, free css, templates, flash slider, HTML" />
<meta name="Description" content="Christmas Night - free CSS template provided by templatemo.com" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="ddsmoothmenu.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="ddsmoothmenu.js">
/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<script type="text/javascript">
ddsmoothmenu.init({
mainmenuid: "templatemo_menu", //menu DIV id
orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
classname: 'ddsmoothmenu', //class added to menu's outer DIV
//customtheme: ["#1c5a80", "#18374a"],
contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})
</script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript">
var flashvars = {};
flashvars.xml_file = "photo_list.xml";
var params = {};
params.wmode = "transparent";
var attributes = {};
attributes.id = "slider";
swfobject.embedSWF("flash_slider.swf", "flash_grid_slider", "900", "290", "9.0.0", false, flashvars, params, attributes);
</script>
<style type="text/css">
a:link {
color: #00F;
}
a:visited {
color: #F00;
}
body,td,th {
color: #FFF;
}
</style>
</head>
<body>
<div id="templatemo_wrapper_outter">
<div id="templatemo_wrapper_inner">
<div id="templatemo_wrapper">
<div id="templatemo_menu" class="ddsmoothmenu">
<ul>
<li><a href="main.html" class="selected">หน้าหลัก</a></li>
<li><a href="head.html" target="topFrame">สมาชิก</a>
<ul>
<li><a href="member_upload.php">Upload Image</a></li>
<li><a href="member_showimage.php">Image All</a></li>
<li><a href="member_update.php">Edit Proflies</a></li>
<li><a href="logout.php">Logout</a></li>
</ul>
</li>
<li><a href="head2.html" target="topFrame">ผู้ดูแลระบบ</a>
<ul>
<li><a href="subpage.html">Show Image</a></li>
<li><a href="subpage.html">Show members</a></li>
<li><a href="subpage.html">Page Three</a></li>
<li><a href="subpage.html">Page Four</a></li>
<li><a href="subpage.html">Page Five</a></li>
</ul>
</li>
<li><a href="formregister.php">ลงทะเบียน</a></li>
<li><a href="about.html">เกี่ยวกับ</a></li>
<li><a href="contact.php">เว็บบอร์ด</a></li>
</ul>
<br style="clear: left" />
</div><!-- end of templatemo_menu -->
<div id="templatemo_header">
<div id="site_title"><h1><a href="main.html">Free CSS Templates</a></h1></div>
</div> <!-- end of header -->
<div id="templatemo_main_top">
<div id="templatemo_bottom">
<?
include('config.inc.php');
mysql_query("SET NAMES UTF8");
$sql = "select * from quiz where id_quiz=$id_quiz";
$dbquery = mysql_db_query($dbname, $sql);
$result = mysql_fetch_array($dbquery);
$id_quiz = $result[id_quiz];
$title = $result[title];
$name = $result[name];
$message = $result[message];
$email = $result[email];
$date_q = $result[date_q];
print "<table width=532 border=1 align=center cellpadding=1 cell spacing=1>";
print "<tr>";
print " <td witdh=703>";
print"<table witdth=532 align=center>";
print"<tr>";
print"<td width=97><font color=ff6600><b>หัวข้อกระทู้</b></font></td>";
print"<td width=417><font color=ff6600><b>".$title."</b></font></td>";
print"</tr>";
print"<tr>";
print"<td width=97><b>รายละเอียด</b></td>";
print"<td width=417>".$message."</b></td>";
print"</tr>";
print"<tr>";
print"<td width=97><b>ผู้ตั้งกระทู้</b></td>";
print"<td width=417>".$name."</b></td>";
print"</tr>";
print"</table>";
print"</td>";
print"</tr>";
print"</table>";
//แสดงคำตอบ
$sql = "select * from ans where id_quiz=$id_quiz order by id_ans";
$dbquery = mysql_db_query($dbname, $sql);
// หาจำนวนเรกคอร์ดข้อมูลในตาราง
$num_rows = mysql_num_rows($dbquery);
if($num_rows==''){
echo "<center>ยังไม่มีคนแสดงความคิดเห็น</center>";
}
$i=0;
while ($i < $num_rows)
{
$result = mysql_fetch_array($dbquery);
$id_ans = $result[id_ans];
$id_quiz = $result[id_quiz];
$name = $result[name];
$message = $result[message];
$email = $result[email];
$date_a = $result[date_a];
$n++;
print"<br>";
print"<table width=532 border=1 align=center cellpadding=1 cellspacing=1>";
print"<tr";
print"<tr>";
print"<td width=703>";
print"<table width=532 align=center>";
print "<tr><div align=center><b>ความคิดเห็นที่$n</b></div></tr>";
print"<tr>";
print"<td width=97><b>รายละเอียด</b></td>";
print"<td width=417>".$message."</td>";
print"</tr>";
print"<tr >";
print"<td width=97><b>จากคุณ</b></td>";
print"<td width=417>".$name."</td>";
print"</tr>";
print"</table>";
print"</td>";
print"</tr>";
print"</table>";
$i++;
}
// ปิดการติดต่อฐานข้อมูล
mysql_close();
?>
<form action="reply.php" method="post" name="form1" id="form1">
<table width="532" border="1" align="center" cellpadding="1" cellspacing="1" >
<tr>
<td width="703"><table width="524"border="0" align="center"cellspacing="1"></td>
</tr>
<tr>
<td colspan="2"><div align="center"><u>แสดงความคิดเห็น</u></div></td>
</tr>
<tr>
<td width="97">ชื่อผู้ตอบ :</td>
<td width="417"><p><? echo $name_post ?></p></td>
</tr>
<tr>
<td >รายละเอียด :</td>
<td ><textarea name="message" col="65" rows="7"wrap="virtual"id="message"></textarea></td>
</tr>
<tr>
<td>รหัสสมาชิก : <? echo $id_post ?></td>
<td > </td>
</tr>
<tr>
<td></td>
<td ><input type="submit" name="submit" value="แสดงความคิดเห็น" />
<input type="reset"name="submit2" value="ยกเลิก" /></td>
<input type="hidden" name="id_quiz" value="<? echo $id_quiz;?>" />
<p><a href="contact.php">กลับสู่ หน้าหลัก </a></p>
</tr>
</form>
</div>
<div id="templatemo_footer">
<div class="cleaner"></div>
</div>
</div>
<div class="cleaner"></div>
</div>
</div>
</body>
</html>
นี้เป็นไฟล์ reply ตอบครับ
Code (PHP)
<? session_start(); ?>
<?
include('config.inc.php');
$date_a=date("d/m/y");
$id_post=$_SESSION['id'];
$name_post=$_SESSION['nickname'];
mysql_select_db($dbname) or die("ไม่สามารถเลือกฐานข้อมูลได้");
mysql_query("SET NAMES UTF8");
$sql = "insert into ans (id_quiz, name, message, email, date_a) values ($id_quiz, '$name_post', '$message', '$id_post', '$date_a')";
$dbquery = mysql_db_query($dbname, $sql);
mysql_close();
echo "<Font Size=4><B>ท่านน $name_post ได้แสดงความคิดเห็นแล้ว </B><BR>";
echo "<A HREF=\"show_ans.php?id_quiz=$id_quiz\">ท่านได้โพสเรียบร้อยแล้ว ".sprintf("<B><FONT COLOR=\"Blue\">%05d</FONT></B>", $id_quiz)."</A>";
?>
Tag : PHP, MySQL, Web (ASP.NET)
|
|
|
|
|
|
Date :
2016-08-04 16:05:32 |
By :
krittipong |
View :
835 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอแนะนำหน่อยครับ เอาเฉพาะส่วนที่คิดว่ามีปัญหามาดูดีกว่าครับ เอามาหมดแล้วนี้เยอะเกิน
ขึ้เกียจไล่ code
|
|
|
|
|
Date :
2016-08-04 16:14:34 |
By :
mee079 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ต้องดูตั้งแต่ insert ข้อมูลมาจริงรึเปล่า และ insert ลง จริงรึเปล่า เช็คที step ตั้งแต่รับค่าตัวแปร
|
|
|
|
|
Date :
2016-08-04 16:17:51 |
By :
dudesaranyu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|