duanniling0018 2015-05-25 22:08
浏览 150

如何将数据库信息作为标题放在表中

I want some information that is stored in my database to be an header in a table.

Basically its got a list of competitors down the side with theirs scores running in rows. Each competitor has their own row. At the top of the table is the name of the event they took part in. I cant manage to make the event name come from the database so got to edit the page each time I add a set of scores.

I have attempted as you will see in the code below;

<?php
require("db_connect.php");
$result = mysql_query("SELECT *, (ct1 + ct2 + ct3 + ct4 + ct5 + ct6) AS results FROM resultsopen WHERE ct='1'");

if(mysql_num_rows($result) == 0) { echo 'No competitors found'; } else {

echo "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\">
        <tr align=\"center\">
        <td>Competitor</td>
        <td>Member No</td>
        <td>" . $row['cta'] . "</td>
        <td>E2</td>
        <td>E3</td>
        <td>E4</td>
        <td>E5</td>
        <td>E6</td>
        <td>E7</td>
        <td>Overall</td>
        <td></td>
        </tr>";

$x=1;
while($row = mysql_fetch_array($result))
    {
    if($x%2): $rowbgcolor = "#FFFFFF"; else: $rowbgcolor = "#EEEEEE"; endif;
    echo "<tr align=\"center\" bgcolor=\"" .$rowbgcolor. "\">";
    echo "<td>" . $row['competitor'] . "</td>";
    echo "<td>" . $row['memberno'] . "</td>";
    echo "<td>" . $row['ct1'] . "</td>";

The line in question is <td>" . $row['cta'] . "</td>

The other lines are just text which I manually change each time.

I also know that mysql should be changed to mysqli but I am not confident in the change just yet.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?