使用php从2个不同的mysql表中获取数据

I'm having trouble getting data from 2 different tables in a profile page.

Actual code looks like this:

<?php
include('db.php');
$sql="SELECT  *  FROM  member  where  mem_id=$loggedin_id";
$result=mysqli_query($db,$sql);
?>
<?php
while($rows=mysqli_fetch_array($result)){
?>

<div id="one">
<form  method="post">   <!-- FORM START -->
<h1 align="center">Profile details</h1>
<table  border="0" cellpadding="2"  cellspacing="0">

<tr>
<td  class="tl-1"><div  align="left"  id="tb-name">Lastname:</div></td>
<td  class="tl-4"><?php  echo  $rows['lastname'];  ?>  </td>
</tr>

<tr>
<td  class="tl-1"><div  align="left"  id="tb-name">Firstname:</div></td>
<td  class="tl-4"><?php  echo  $rows['firstname'];  ?></td>
</tr>
<tr>
<td  class="tl-1"><div  align="left"  id="tb-name">Username:</div></td>
<td  class="tl-4"><?php  echo  $rows['username'];  ?></td>
</tr>
<tr>
<td  class="tl-1"><div  align="left"  id="tb-name">Your wish:</div></td>
<td  class="tl-4"><?php  echo  $rows['wish'];  ?></td>

At Your Wish i need to echo the wish stored in a different table called "wish".

Any help is much apreciated.

I am assuming that the field name in your wish table is wish and the foreign key is member_id. So then, Try like this..

  <?php
        include('db.php');
        $sql="SELECT  member.*, wish.wish FROM  member JOIN wish ON member.mem_id=wish.member_id  WHERE  member.mem_id=$loggedin_id";
        $result=mysqli_query($db,$sql);
   ?>