Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 468
0 Users 1 Guests Online
Forum Index » PHP + MySQL » Help with PHP Code
Posted on Saturday 2nd June 2007 at 11:22 PM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
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
2
$id = (int)$_GET['id'];
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
templates/default/images/noavatar.png's Avatar
Senior Member
You wouldn't use id. Use their username.

Much easier.
Posted on Sunday 3rd June 2007 at 01:02 AM
Diablosblizz
templates/default/images/noavatar.png's Avatar
Senior Member
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
templates/default/images/noavatar.png's Avatar
Senior Member
Well in the pm you would do.

PHP Code
1
2
3
$fetch = mysql_query("SELECT * FROM `DBNAME` WHERE `to` = '$logged[username]' LIMIT 0, 1");
$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
avatars/1.png's Avatar
Senior Member
PHP Code
1
2
3
4
5
6
7
8
9
10
11
<?
$id 
= (int)$_GET['id']; 
$fetch mysql_query("SELECT * FROM `*DBNAME*` WHERE `id` = '$id'");
$pm mysql_fetch_array($fetch); 
//$pm[id] and $id will be the same
if($pm[to] == $logged[username]) {
//There PM
}else{
//Not there PM
}
?>