Page 1 of 1

provide hyperlink for record in database

Posted: Wed Mar 31, 2004 9:39 am
by manish_7in
hi

I will try to explain my problem as much as i can....

I am designing a message system in php. I have a messages table which have the following fields: receiver_id,sender_id,subject,message,date

I can display the messages for a particular user by querying the messages table and returning all the records which have that members id in the reciever_id field.I display the messages in a html table with columns:sender,subject and date.

Now what i want is that when the user clicks on the subject of the message he should be taken to that message.(maybe by giving the hyperlink to subject). I am not able to work out how to do this.(how to set a variable in php equal to the subject of message and then query the database using the subject can be one option, but i am not able to figure it out how to do this..how to get the subject field content if there are many messages and how to figure out which hyperlink the user clicked?)

Any suggestion or help would be appreciated.
Thanks
MANISH

Posted: Wed Mar 31, 2004 9:46 am
by lostboy
the hyperlink should provide the primary key or enough info to obtain the record...

from your table field list, i don't see a primary key, though it could be a concatenated key of several fields...usually a pk is some knd of autonumber key or even a random key generated by a function (kina like phpsessid) since your table could have multiple records having the same information (ie one sender could send one receiver many notes on the same day on the same subject...an you don't want to pass the message around...

Posted: Wed Mar 31, 2004 10:50 am
by manish_7in
The primary key can be generated by combining sender_id and date/time field which will be unique..

Posted: Wed Mar 31, 2004 12:38 pm
by lostboy
so pass that value in the url and $_GET the value...pass that to the db...