English 中文(简体)
每一行以数字表示的超文本表格(PHP + MYSQL)
原标题:Label each row of an HTML table numerically (PHP + MYSQL)

我所希望的是,我桌上每行一栏显示目前行数。 例如,请见下表。

Column Header 1    Column Header 2
1                     some data
2                     more data
3                     some more data
4                     even more data

我很熟悉 Java本(我最有可能理解任何已张贴的联合材料)、中央支助事务和超文本。 我很想知道,我是否必须写一份联合材料,以便这样做,或者如果我能够做些什么,就只能产生一个变数,每增加一个指数。

我期待着你们的答复!

最佳回答

如果你重新使用PHP,就设法获得你想要产出的数据的阵列:

$data = array( here ,  is ,  some ,  data );

// Avoid printing table if there is no data
if (count($data) > 0) {
    echo  <table><tr><td>Column Header 1</td><td>Column Header 2</td></tr> ;
    for ($i = 0; $i < count($data); $i++) {
        echo  <tr><td> , $i + 1,  </td><td> , $data[$i],  </td></tr> ;
    }
    echo  </table> ;
}
问题回答

Does it have to be a table, or could you use an ol?

<ol>
    <li>some data</li>
    <li>more data</li>
    <li>some more data</li>
    <li>even more data</li>
</ol>

Based on kisp s approach of CSS numbering, I created a prototype which appears to do almost what you are looking for. The numbering isn t in a separate collumn, it s in the "before" pseudo-element.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签