問題描述
我對(duì)此很陌生,不知道該怎么做,
i'm pretty new to this and not sure how should i do it,
我有一個(gè)數(shù)據(jù)庫,其中有一列名為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>
我只知道如果記錄在垂直方向上一個(gè)接一個(gè)地排列,我應(yīng)該怎么做.
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>';
有點(diǎn)卡在這里...
對(duì)不起,我忘了放這個(gè).
Sorry i forgot to put this.
我想要的是它應(yīng)該循環(huán)標(biāo)簽.所以我可以有一個(gè)包含無限行的 3 列表.
what i want is that it should loop the tags along. So i can have a 3 column table with infinite rows.
這個(gè)呢?如果我想讓它循環(huán)怎么辦?
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
將在循環(huán)的每次迭代中更新:
$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>';
這篇關(guān)于Mysql 取數(shù)組、表結(jié)果的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!