本文介紹了Mysql 取數組、表結果的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我對此很陌生,不知道該怎么做,
i'm pretty new to this and not sure how should i do it,
我有一個數據庫,其中有一列名為names"
I've got a database with a column called "names"
我怎樣才能讓它顯示出來?
how can i make it display in so?
<tr>
<td width="270px">Henry</td>
<td width="270px">Jeffrey</td>
<td width="270px">Hansel</td>
</tr>
<tr>
<td width="270px">Michelle</td>
<td width="270px">Jackson</td>
<td width="270px">Ivan</td>
</tr>
我只知道如果記錄在垂直方向上一個接一個地排列,我應該怎么做.
I only know how i should do it if the records goes one after another vertically.
$result = mysql_query('SELECT * FROM member');
while($row = mysql_fetch_array($result))
{
echo'
<tr>
<td width="270px">'.$row['names'].'</td>
<td width="270px">Jeffrey</td>
<td width="270px">Hansel</td>
</tr>';
有點卡在這里...
對不起,我忘了放這個.
Sorry i forgot to put this.
我想要的是它應該循環標簽.所以我可以有一個包含無限行的 3 列表.
what i want is that it should loop the tags along. So i can have a 3 column table with infinite rows.
這個呢?如果我想讓它循環怎么辦?
what bout this one? What if i want this to loop instead?
<tr>
<td><img src="images/ava/A.png" /></td>
<td>A</td>
<td width="2px" rowspan="3"></td>
<td><img src="images/ava/B.png" /></td>
<td>B</td>
</tr>
<tr>
<td>A</td>
<td>B</td>
</tr>
推薦答案
$row
將在循環的每次迭代中更新:
$row
will update on each iteration of the loop:
$result = mysql_query('SELECT * FROM member');
echo '<tr>';
for($i = 0; $row = mysql_fetch_array($result); $i = ($i+1)%3){
echo '<td width="270px">'.$row['names'].'</td>';
if($i == 2)
echo '</tr><tr>';
}
echo '</tr>';
這篇關于Mysql 取數組、表結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!