ajloun
10-14-2009, 09:38 PM
Hello
I have Simple Script , Messages between Members .
i have two tabels on has users name and id , email.. another tabel for messages has message id , subject, from, to, text
Now the code Below Shows the messages between the users . the code Shows Message ID , From, To , Subject, Text .
But where "from" and "to" replaced with user ID , and i want it to be replaced with the User Name .. from the other Tabel ..
like if user id =100 get user name from table users where ID=100
this the code i use
$result = mysql_query("SELECT * FROM ".$DB->prefix("msgs")." LIMIT 10");
$rows = mysql_num_rows($result);
if($rows > 0){
echo "<table width='700' border='1'>
<tr>
<td>";
echo "<table border='1' width='100%'>";
echo "<tr>";
echo "<td width='15%'><b>ID</b></td> ";
echo " <td width='15%'><b>From</b></td><td width='15%'><b>To</b> ";
echo " <td width='15%'><b><p>Subject</p></b>";
echo "</td><td width='45%'><b>Message</b></td>" ;
echo "</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td width='15%'>".$row['id']."</td>";
echo "<td width='15%'>".$row['from']."</td> ";
echo "<td width='15%'>".$row['to']."</td> ";
echo "<td width='15%'>".$row['subject']."</td> ";
echo "<td width='45%'>".$row['msg']."</td> ";
}
echo "</table>";
echo "</td> ";
echo " </tr> ";
echo " </table>";
}
I have Simple Script , Messages between Members .
i have two tabels on has users name and id , email.. another tabel for messages has message id , subject, from, to, text
Now the code Below Shows the messages between the users . the code Shows Message ID , From, To , Subject, Text .
But where "from" and "to" replaced with user ID , and i want it to be replaced with the User Name .. from the other Tabel ..
like if user id =100 get user name from table users where ID=100
this the code i use
$result = mysql_query("SELECT * FROM ".$DB->prefix("msgs")." LIMIT 10");
$rows = mysql_num_rows($result);
if($rows > 0){
echo "<table width='700' border='1'>
<tr>
<td>";
echo "<table border='1' width='100%'>";
echo "<tr>";
echo "<td width='15%'><b>ID</b></td> ";
echo " <td width='15%'><b>From</b></td><td width='15%'><b>To</b> ";
echo " <td width='15%'><b><p>Subject</p></b>";
echo "</td><td width='45%'><b>Message</b></td>" ;
echo "</tr>";
while($row = mysql_fetch_array($result)){
echo "<tr><td width='15%'>".$row['id']."</td>";
echo "<td width='15%'>".$row['from']."</td> ";
echo "<td width='15%'>".$row['to']."</td> ";
echo "<td width='15%'>".$row['subject']."</td> ";
echo "<td width='45%'>".$row['msg']."</td> ";
}
echo "</table>";
echo "</td> ";
echo " </tr> ";
echo " </table>";
}