Jump to content

[SOLVED] Php inserting into a linker table


deansaddigh

Recommended Posts

Hi,

 

I have a problem and am trying to figure out the best way to solve it...

 

I have three tables

 

post

user_post

user

 

When a user creates a post I want to store this in the post and user post table. They have to be logged in to do so. The problem i have is inserting data into the user_post table I have a problem.

 

In order to write to the user_post table I need to have the userid and the postid. Getting the userid is not a problem as i already have this detail stored in the session. To get the post id ready to insert into the user_post table I have no 'full proof' way of doing so. As there is nothing unique in the post table apart from the post id which i am trying to access I have no way of querying it to get this result.

 

The only options that i can think of are:

 

 

select the max postid and take that assuming that this must be the one that the user has entered

 

OR

 

select the postid based on the post text and datetime stamp.

 

However if multiple users post at similar time with the same message etc this would become a problem#

 

Any suggestions would be much appreciated

 

Thanks

 

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.