[英]Showing Images Side by Side in a Table
我試圖並排顯示5個圖像(50x50),但不是並排顯示圖像,而是將每個圖像顯示在單獨的行中。如何解決此問題?
$i = 0;
while ($row = $result->fetch_object()) {
echo "<tr>";
if ($last_entry != $row->project) {
echo "<td align='center'><textarea name ='project' rows='16' cols='30' style='resize: none'>".$row->project."</textarea></td>";
echo "<td align='center'>".$row->uid."</td>";
echo "<td align='center'>".$row->parent_cat."</td>";
echo "<td align='center'><textarea name ='project_desc' rows='16' cols='30' style='resize: none'>".$row->project_desc."</textarea></td>";
echo "<td align='center'><textarea name ='desc' rows='16' cols='30' style='resize: none'>".$row->desc."</textarea></td>";
echo "<td align='center'>".$row->copyright."</td>";
echo "<td align='center'>Buttons</td>";
echo "</tr>";
echo "<tr>";
$last_entry = $row->project;
}
//echo "<td align='center' colspan='6'><img src=".$row->url."<border='0'></td>";
//echo "<td align='center' colspan='7'>";
echo "<td colspan='7'><a href='".$row->url."' data-lightbox='".$row->file_name."' data-title='".$row->file_name."'><img src='".$row->url."' border='0' width='50' height='50'></a></td>";
if ($i%5==0) {
echo "</tr><tr>";
}
$i++;
if (!$i%5 == 0) {
echo "<td colspan='7'> </td>";
}
}
//echo "</td>";
//echo "</tr>";
echo "</table>";
這幾乎可以正常工作,但是在顯示第一個圖像之后,將進行休息,然后將所有圖像並排顯示...
while ($row = $result->fetch_object()) {
if ($last_entry != $row->project) {
echo "<div class='box-white'>";
echo "<div class='divTable'>";
echo "<div class='divTableBody'>";
echo "<div class='divTableRow'>";
echo "<div class='divTableCell'>Projektnamen</div>";
echo "<div class='divTableCell'>UID</div>";
echo "<div class='divTableCell'>Kategorie</div>";
echo "<div class='divTableCell'>Projektbeschreibung</div>";
echo "<div class='divTableCell'>Beschreibung</div>";
echo "<div class='divTableCell'>Copyright</div>";
echo "<div class='divTableCell'>Tools</div>";
echo "</div>";
echo "</div>";
echo "</div>";
echo "<div class='divTableBody'>";
echo "<div class='divTableRow'>";
echo "<div class='divTableCell'><textarea name ='project' rows='16' cols='30' style='resize: none'>".$row->project."</textarea></div";
echo "<div class='divTableCell'>".$row->uid."</div>";
echo "<div class='divTableCell'>".$row->parent_cat." </div>";
echo "<div class='divTableCell'><textarea name ='project_desc' rows='16' cols='30' style='resize: none'>".$row->project_desc."</textarea></div>";
echo "<div class='divTableCell'><textarea name ='beschreibung' rows='16' cols='30' style='resize: none'>".$row->beschreibung."</textarea></div>";
echo "<div class='divTableCell'>".$row->copyright."</div>";
echo "<div class='divTableCell'>Buttons</div>";
echo "</div>";
echo "</div>";
$last_entry = $row->project;
}
echo "<div class='divTableCell'><div style='float:left'><a href='".$row->url."' data-lightbox='".$row->file_name."' data-title='".$row->file_name."'><div class='center-cropped'><img src='".$row->url."' border='0'</a></div></div></div>";
echo "</div>";
}
感謝您的支持和建議!
親切的問候,
斯特凡
這是在表中(並排)呈現5張圖像的非常基本的方法,也許可以幫助您解決問題:
<!DOCTYPE html>
<html>
<body>
<?php
$pics = array('pic1.jpg', 'pic2.jpg', 'pic3.jpg', 'pic4.jpg', 'pic5.jpg');
echo "<table style='border: 1px solid blue'>";
echo '<tr>';
for ($i=0; $i<5; $i++)
{
$html = <<<HEREDOC_DELIM
<td style='border: 1px solid red'>
<img src="{$pics[$i]}" alt="sometext" width="50" height="50">
</td>
HEREDOC_DELIM;
echo $html;
}
echo '</tr>';
echo '</table>';
?>
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.