Messaging system
Posted: Tue Sep 07, 2004 11:45 am
Hey, i'm trying to make a messaging system for my users, and all works fine except my script is only displaying one row from the DB.
i put it into a functioin called getMessages(), here's the function:
Is there something wrong with the function ? cus i thought that by using a while loop it grabs all of the rows .. ?
Any help is appreciated...
*EDIT* I just tried the script out of the function, and it works ok...how can i make it work within the function ?? or will i just have to scrap it ? lol
i put it into a functioin called getMessages(), here's the function:
Code: Select all
function getMessages() {
mysql_connect("localhost","****","****");
mysql_select_db("****");
$player = $_SESSIONї'charactername'];
$sql = "SELECT * FROM messages WHERE `receiver`='$player'";
$grabem = mysql_query($sql) or die(mysql_error());
while($fields=mysql_fetch_array($grabem))
{
$date=$fieldsї'date'];
$id=$fieldsї'message_id'];
$sender_name=$fieldsї'sender_name'];
$subject=$fieldsї'subject'];
$sender_id=$fieldsї'sender_id'];
$player_id=$fieldsї'player_id'];
$message=$fieldsї'message'];
$display = "&nbsp;&nbsp;&nbsp;".$date."<br>";
$display .= "&nbsp;&nbsp;&nbsp;From: ".$sender_name."(".$sender_id.")";
$display .= "<br>";
$display .= "&nbsp;&nbsp;&nbsp;Subject: ".$subject;
$display .= "<br>";
$display .= "&nbsp;&nbsp;&nbsp;".$message;
$display .= "<br><center><a href='game.php?page=reply&name=".$sender_name."&id=".$sender_id."'>Reply</a>";
$display .= " | <a href='process.php?action=delete_message&id=".$id."'>Delete</a>";
$display .= "<hr></center>";
return $display;
}
}Any help is appreciated...
*EDIT* I just tried the script out of the function, and it works ok...how can i make it work within the function ?? or will i just have to scrap it ? lol