I'm Beginner. I need help, please. I am having a small problem in the script I am have in this script ( admin folder) Add contain articles (This page is working to add threads only) My problem in the Page (read_mor.php) i make a query with the database to bring news this is query .
<?php
include ('config/connect_to_mysql.php');
$id = $_GET["id"];
$fetch = mysql_query("SELECT * FROM posts WHERE id= '$id' ") or die(mysql_error());
while($myrow = mysql_fetch_assoc($fetch)) {
?>
<?php echo $myrow['title']; ?>
<?php echo $myrow['created_on']; ?>
<?php echo $myrow['categories']; ?>
<?php echo $myrow['description']; ?>
<?php echo $myrow['categories']; ?>
<?php } ?>
everything is v god
but when i insert comment in table (comments) all comments in table show with any post ..!!
i need to insert comment with article by id article
this page for insert comment
<?php
include ('config/connect_to_mysql.php');
$query="INSERT INTO comments (com_id,name,url,email,comment,postid)
VALUES
('', '$_POST[name]' , '$_POST[url]', '$_POST[email]', '$_POST[comment]', LAST_INSERT_ID(postid))" or die(mysql_error());
if ($query)
$result = mysql_query($query);
{
echo "<strong>Thanks!</strong><p>Your message was successfully sent.</p>";
}
?>
Table in database ---- >
comments
structure for table `comments`
(
`com_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '',
`comment` text COLLATE utf8mb4_unicode_ci NOT NULL,
`dt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`yes` int(11) NOT NULL,
`postid` int(11) NOT NULL,
PRIMARY KEY (`com_id`)
) ENGINE=MyISAM DEFAULT
table of posts ------>
CREATE TABLE IF NOT EXISTS `posts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL,
`description` longtext NOT NULL,
`categories` varchar(200) NOT NULL,
`post_meta` varchar(200) NOT NULL,
`post_robots` varchar(200) NOT NULL,
`meta_title` varchar(200) NOT NULL,
`meta_description` text NOT NULL,
`created_by` varchar(100) NOT NULL,
`created_on` datetime NOT NULL,
`imageref` varchar(300) NOT NULL,
`post_status` varchar(70) NOT NULL DEFAULT 'published',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=102 ;
When i do submit comment inserting but when i open the post all comment will show because ID in posts table is not associated with the postid in comment
so i need when i post comment - comment show with post by id how can i insert postid in comments table with id in posts table and how can show topic with comment : if i used inner join How can i used it .. !!