I have two table named: Blog for displaying blogs post and comments for displaying comments section for each blog post.
The fields for these are as follows:
Now what i want is that suppose for blog_id = "2", I am writing comment, so what would be the insert query so that when i visit index.php?blog_id=2, I get the comments for only that particular post.
I mean how to insert the comments for a particular blog_id?
I tried this query to insert:
INSERT INTO cms.comments(blog_id, name,email,comments_body) VALUES ( '".$arr['blog_id']."', '".$arr['name']."', '".$arr['email']."', '".$arr['comments_body']."' ) WHERE cms.blog.blog_id = '$cms.blog.blog_id'");
I tried the foreign key concept : SELECT @last := LAST_INSERT_ID(), but coud not understand how to use this.