Help with PHP Code

Posted on Saturday 2nd June 2007 at 11:22 PM
Diablosblizz
Diablosblizz's Avatar
Hey, I am trying to make a PM system for my site. The only problem is how do I get the ID!!!

I will make the ID the primary key, but there are multiple users, so how would I get the ID that matches with the users Username?

I am lost and I don't understand what I am susposed to do.

DanielXP said to use this:

PHP Code
  1. $id = (int)$_GET['id'];
  2. echo $id;


But I don't understand how that will get the ID from the mysql and target the user to their message.

Please help!
Posted on Sunday 3rd June 2007 at 12:47 AM
SkillMaster
SkillMaster's Avatar
You wouldn't use id. Use their username.

Much easier.
Posted on Sunday 3rd June 2007 at 01:02 AM
Diablosblizz
Diablosblizz's Avatar
I just don't understand how I would get it to show one message of the 5 that they will be allowed to store.
Posted on Sunday 3rd June 2007 at 04:57 AM
SkillMaster
SkillMaster's Avatar
Well in the pm you would do.

PHP Code
  1. $fetch = mysql_query("SELECT * FROM `DBNAME` WHERE `to` = '$logged[username]' LIMIT 0, 1");
  2. $pm = mysql_fetch_array($fetch);


"to" is like the message recepient so change it accordingly.
Posted on Wednesday 6th June 2007 at 03:01 PM
DanielXP
DanielXP's Avatar
PHP Code
  1. <?
  2. $id = (int)$_GET['id'];
  3. $fetch = mysql_query("SELECT * FROM `*DBNAME*` WHERE `id` = '$id'");
  4. $pm = mysql_fetch_array($fetch);
  5. //$pm[id] and $id will be the same
  6. if($pm[to] == $logged[username]) {
  7. //There PM
  8. }else{
  9. //Not there PM
  10. }
  11. ?>
Login or register to respond to this forum topic.