I have 2 tables that have been joined using the ID that correlates the data on both tables. I output the information perfectly.
I output ID and it returns that of the ID column in table_1 - PERFECT. But now I want to output the ID column in table_2 within the same statement.
How do I now say ID from table_2, not table_1?
Here's some code...
$who = $_SESSION['who'];
$data = mysql_query("SELECT * FROM tbl_messages INNER JOIN tbl_users ON tbl_messages.from_user = tbl_users.id WHERE tbl_messages.to_user = $who")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo "From:" . $info['id'];
echo "to:" . $info['id'];
}
one good way to do this is to say
SELECT tbl_messages.id as msgID, tbl_users.id as usrID, * FROM tbl_messages INNER JOIN tbl_users ON tbl_messages.from_user = tbl_users.id WHERE tbl_messages.to_user = $who
Then you will reference the fields with that name
echo "From:" . $info['msgID'];
echo "to:" . $info['usrID'];