provide hyperlink for record in database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
manish_7in
Forum Newbie
Posts: 4
Joined: Thu Feb 26, 2004 8:03 pm

provide hyperlink for record in database

Post 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
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post 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...
manish_7in
Forum Newbie
Posts: 4
Joined: Thu Feb 26, 2004 8:03 pm

Post by manish_7in »

The primary key can be generated by combining sender_id and date/time field which will be unique..
lostboy
Forum Contributor
Posts: 329
Joined: Mon Dec 30, 2002 8:12 pm
Location: toronto,canada

Post by lostboy »

so pass that value in the url and $_GET the value...pass that to the db...
Post Reply