Jump to content

[SOLVED] grab an id from the address bar and post it to a mysql database


maztrin

Recommended Posts

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

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.