-3

我是否可以在从另一个表中提取用户名字和姓氏的指导方面获得一些帮助,我已经调用成员来显示我已经从一个名为 folio 的表中显示的信息中的数据,关于我需要在此代码中的何处添加的任何想法加入?

见下文:

  <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>
4

2 回答 2

0

JOIN在查询中使用 a :

SELECT f.*, m.firstname, m.lastname
FROM folio f 
    INNER JOIN members m ON f.userid = m.id
ORDER BY f.dateadded DESC
于 2013-07-13T22:45:55.047 回答
0

您可以执行以下操作,具体取决于表中的列名members

$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';

然后

$row['firstname'] // first name
$row['lastname']  // last name
于 2013-07-13T22:47:49.187 回答