使用php和mySQL数据库拉取数据[关闭]

May I have some assistance with guidance on pulling the users first name & last name from another table I have called members to show data within the information I am already showing from a table called folio, any ideas on where in this code I need to add a JOIN?

See below:

  <div id="latest">
  <?php 
    $query = 'SELECT * FROM folio ORDER BY dateadded DESC';
    $result = mysqli_query($connection, $query);
    if(!$result){
        die('Database error: '.mysqli_error($connection));
    }
    while($row = mysqli_fetch_assoc($result)){
        ?>
       <div class="outimgbox"> <a style="text-decoration: none;" href="temp.php?imgid=<?php echo $row['imgid']; ?>">
    <div id="mainwrapper">
        <div id="box-3" class="box"> <img class="uploads" src="uploads/folio/<?php echo $row['filename']; ?>" /> <span class="caption fade-caption">
           <h3><?php echo $row['title']; ?></h3>

        <p style="color: #2d2d2d; font-size: 12px; padding-left:2px; padding-top:2px; margin-top: 16px; text-decoration: none;"><?php echo $row['description']; ?></p>



          </span></div>


      </div>
      </a> 
      </div>

Use a JOIN in your query:

SELECT f.*, m.firstname, m.lastname
FROM folio f 
    INNER JOIN members m ON f.userid = m.id
ORDER BY f.dateadded DESC

You could do something like this, depending on what the column names are in your members table:

$query = 'SELECT f.*, m.firstname AS firstname, m.lastname AS lastname FROM folio AS f, members AS m WHERE f.userid = m.id ORDER BY dateadded DESC';

then

$row['firstname'] // first name
$row['lastname']  // last name