maztrin Posted February 15, 2009 Share Posted February 15, 2009 hi, i am trying to create my own simple post/comments scripts. i have managed to set up all the topics so that they each have their own id. eg: www.site.com/topic.php?id=4 i am trying to associate the posts and replies using an id. i have 2 mysql tables:1) - posts and 2) - postReplies in the posts table there is a post_ID that each post is given. when a user makes a reply to a post it saves to the database postReplies but how do i get it so that when a user makes a reply the post_ID that was made for the original post is saved in the post_ID column that is also in the postReplies column. im using php and mysql i hope i described my problem accurately. any help would be appreciated. thanks trin edit: ive looked into it a little bit and i think i need to use this $_GET method which i have used before but am a little stumped about how to use it to post the id to the database Link to comment https://forums.phpfreaks.com/topic/145342-solved-grab-an-id-from-the-address-bar-and-post-it-to-a-mysql-database/ Share on other sites More sharing options...
allworknoplay Posted February 15, 2009 Share Posted February 15, 2009 Here is your URL: www.site.com/topic.php?id=4 If you want to get the $_GET, you would call: $_GET[id]; Link to comment https://forums.phpfreaks.com/topic/145342-solved-grab-an-id-from-the-address-bar-and-post-it-to-a-mysql-database/#findComment-763020 Share on other sites More sharing options...
maztrin Posted February 15, 2009 Author Share Posted February 15, 2009 i am already using get i just dont know how to implement it. my code: $id=$_GET['post_ID']; // rest of my code does other stuff $query = "INSERT INTO postReplies(post_ID, postreply) VALUES ('$id', '$reply' )"; $result = @mysql_query ($query); the post_ID is from another table. but when a user posts it will take the post_ID and post it into the postReplies table. note: the post_ID that i am trying to get to post to the Database is already being used once in the script (in another block of code) to display the post already. could this be affecting it? Link to comment https://forums.phpfreaks.com/topic/145342-solved-grab-an-id-from-the-address-bar-and-post-it-to-a-mysql-database/#findComment-763040 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.