|
 |
|
เขียนโค้ด php ทำคอมเม้นกับโพสต์ มันมีปัญหาตรงที่ถ้าโพสต์หลายๆ อัน แล้วต้องการจะไปคอมเม้นโพสต์แรกไม่ได้ แต่คอมเม้นโพสต์สุดท้ายได้โพสต์เดียว ไม่รู้ว่าเขียนโค้ดยังไงให้สามารถคอมเม้นได้ทุกโพสต์ |
|
 |
|
|
 |
 |
|
*******************************หน้า post***********************************
Code (PHP)
<? session_start(); ?>
<!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>
<?
?>
<? //post
//$hidden_id = $_POST['id'];
$sid = $_SESSION['sid'] ;
$pid = $_SESSION['pid'] ;
include('../member/include.php');
if($_POST['pos']=="post"){
$pmess = $_POST['post'];
$pdate = date('d/m/Y');
$ptime = date('h:m:s');
$sqlp = "insert into tbl_post";
$sqlp .= "(post_id,member_id,post_massage,post_date,post_time) values (NULL,'$sid','$pmess','$pdate','$ptime')";
$queryp = mysql_query($sqlp);
echo "<meta http-equiv='refresh' content='0;url=pro_file.php'/>";
//ment
}else if($_POST['pos']=="comment"){
$cmess = $_POST['comment'];
$cdate = date('d / m / Y');
$ctime = date('h:m:s');
if ($cmess <> ""){
$sqlm = "insert into tbl_comment ";
$sqlm .="(comment_id,comment_massage,comment_date,comment_time,post_id,member_id) values (NULL,'$cmess','$cdate','$ctime','$pid','$sid')";
$querym = mysql_query($sqlm);
echo "<meta http-equiv='refresh' content='0;url=pro_file.php'/>";
}
}
?>
</body>
</html>
*******************************หน้า check _post***********************************
Code (PHP)
<? session_start(); ?>
<!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>
<?
?>
<? //post
//$hidden_id = $_POST['id'];
$sid = $_SESSION['sid'] ;
$pid = $_SESSION['pid'] ;
include('../member/include.php');
if($_POST['pos']=="post"){
$pmess = $_POST['post'];
$pdate = date('d/m/Y');
$ptime = date('h:m:s');
$sqlp = "insert into tbl_post";
$sqlp .= "(post_id,member_id,post_massage,post_date,post_time) values (NULL,'$sid','$pmess','$pdate','$ptime')";
$queryp = mysql_query($sqlp);
echo "<meta http-equiv='refresh' content='0;url=pro_file.php'/>";
//ment
}else if($_POST['pos']=="comment"){
$cmess = $_POST['comment'];
$cdate = date('d / m / Y');
$ctime = date('h:m:s');
if ($cmess <> ""){
$sqlm = "insert into tbl_comment ";
$sqlm .="(comment_id,comment_massage,comment_date,comment_time,post_id,member_id) values (NULL,'$cmess','$cdate','$ctime','$pid','$sid')";
$querym = mysql_query($sqlm);
echo "<meta http-equiv='refresh' content='0;url=pro_file.php'/>";
}
}
?>
</body>
</html>
Tag : PHP, HTML/CSS

|
|
 |
 |
 |
 |
Date :
2012-02-16 17:20:38 |
By :
a |
View :
1444 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$querym = mysql_query($sqlm) or die(mysql_error());
|
 |
 |
 |
 |
Date :
2012-02-17 06:39:07 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|