Mysql 取数组、表结果

Mysql fetch array, table results(Mysql 取数组、表结果)
本文介绍了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 取数组、表结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Why can#39;t I update data in an array with foreach loop?(为什么我不能用 foreach 循环更新数组中的数据?)
Foreach for arrays inside of an array(Foreach 用于数组内的数组)
PHP array get next key/value in foreach()(PHP 数组在 foreach() 中获取下一个键/值)
Using preg_match on a multidimensional array to return key values arrays(在多维数组上使用 preg_match 返回键值数组)
php foreach as key, every two number as a group(php foreach 为key,每两个数字为一组)
Treat a PHP class that implements Iterator as an array(将实现 Iterator 的 PHP 类视为数组)