私のスクリプトであなたの助けが必要です。一部のコンテンツヘッダーをアーカイブボックスに入れて、ヘッダーをクリックするとコンテンツが表示されるWebサイトがあります。私の問題は、各ページで行われるコメントについてです。
通常、私はGETでページIDを渡します。したがって、GETが設定されていない場合、つまり、表示されている記事が現在の記事であり、そのIDがWHEREクエリに手動で渡されます。
問題は、古いアーカイブの記事にユーザーが残したコメントが、それぞれの記事ページに表示されないことですが、IDを手動で渡した記事には表示されません。この問題を解決するにはどうすればよいですか
これが私が機能させようとしているコードの一部です。
お手数をおかけしますが、何卒よろしくお願い申し上げます。
$page_name = 'about';
$id = "";
if (isset($_GET['id'])) {
$id = $_GET['id'];
//display content based on the header clicked
} else {
//display content of the current article based on the id. I pass the numeric id of the current article into the where clause that selects the content
//it displays
}
$query6 = mysql_query(" SELECT c.body FROM comment AS c
INNER JOIN about AS a ON
c.article_id = a.about_id
WHERE c.article_id = 3
AND page_name = '".$page_name."'")
コメント表
CREATE TABLE IF NOT EXISTS`comment`(
`comment_id` int(255),
`article_id` int(255),
`username` varchar(255) ,
`page_name` varchar(255) ,
`comment_body` varchar(300),
`comment_date` datetime,
PRIMARY KEY (`comment_id`)
テーブルについて
CREATE TABLE IF NOT EXISTS `about` (
`about_id` int(255),
`about_head` varchar(255)
`about_content` varchar(4000),
`about_tags` varchar(255) ,
`about_created` datetime,
古い記事のURL
http://localhost/root/about.php?id=3
現在の記事のURLは
http://localhost/root/about.php
現在の記事であるため、動的IDを渡すことはできません。クエリで'"。$id。"'を実行し、現在の記事をクリックすると、何も表示されません。