我试图从数据库服务器回显网站中的事件记录。下面的代码以横向格式显示记录,但我希望它是垂直的。
Echo.php文件
<?php
//Connect to database
$con=mysqli_connect("#", "#", "", "#");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Query to select all publications from the 'files' table
$result = mysqli_query ($con,"SELECT * FROM event ORDER BY event_date DESC LIMIT 4");
//Echo out table
while($row = mysqli_fetch_array($result))
//Echo out the publication details
{
echo "<table class='table' border='0'>
<tr>
<td>
<a href='business_profile.php?id={$row['event_id']}'> ".$row['event_name'] ." </a>
</td>
<td>
<img width='190' height='180' src='data:image/jpeg;base64,".base64_encode($row['event_pic'])."'/>
</td>
<td>" . $row['event_info'] . "</td>
</tr>";
echo "</table>";
}
?>
目前它呈现,
event1 event1_pic event1_info
event2 event2_pic event2_info ..so on
但是我希望代码在块中显示如下
event1 event 2
event1_pic event2_pic
event1_info event3_pic
答案 0 :(得分:2)
<tr>
标签是一个表格行。你可以放多个
<td>
标记在每行上创建表格单元格。示例:
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
这将很快让您熟悉基本的html表结构: http://www.w3schools.com/html/html_tables.asp