水平显示数据而不是垂直显示数据?

时间:2015-12-14 17:48:30

标签: php html css

我有一个从数据库获取数据的表。我希望水平呈现每个工作人员,但它目前正在垂直显示。

include 'includes/connect.php';

$select_staff = "select * FROM staff";

$run_staff = mysql_query($select_staff);

while ($row_staff=mysql_fetch_array($run_staff))
{
    $staff_id = $row_staff['staff_id'];
    $staff_name = $row_staff['staff_name'];
    $staff_details = $row_staff['staff_details'];
    $staff_image = $row_staff['staff_image'];

    echo
        "<table><tr><td>{$row_staff ['staff_name']}</td></tr>
        <tr>  <td>{$row_staff['staff_details']}</td></tr>
          <tr><td><img src='images/$staff_image' width='100' height='100'/></td>
               </tr></table>";
}

目前显示:

Name
Details
Image

Name
Details
Image

我希望它显示:

Name                       Name

Details                    Details

Image                      Image

1 个答案:

答案 0 :(得分:0)

Try the following way:

include 'includes/connect.php';

$select_staff = "select * FROM staff";

$run_staff = mysql_query($select_staff);
echo "<table>;

while ($row_staff=mysql_fetch_array($run_staff))
{
    $staff_id = $row_staff['staff_id'];
    $staff_name = $row_staff['staff_name'];
    $staff_details = $row_staff['staff_details'];
    $staff_image = $row_staff['staff_image'];

    echo
        "<tr><td>{$row_staff ['staff_name']}</td>
             <td>{$row_staff['staff_details']}</td>
             <td><img src='images/$staff_image' width='100' height='100'/></td>
         </tr>";
}

echo "</table>";