我似乎无法在下面的脚本中找到错误。我已经检查了一段时间了。抱歉,我对 SQL 和 PHP 很陌生。

    $tCompany_SQLselect = "SELECT ";
    $tCompany_SQLselect .= "ID, preNAME, Name, RegType ";
    $tCompany_SQLselect .= "FROM ";
    $tCompany_SQLselect .= "tCompany ";

    $tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect);

    $index = 1;
    while ($row = mysql_fetch_array($tCompany_SQLselect_Query, MYSQL_ASSOC)) {
        $preNAME = $row['preNAME'];
        $Name = $row['Name'];
        $RegType = $row['RegType'];

        echo $index.".".$preNAME."".$Name."".$RegType" <br />;

        $index++;

    }
有帮助吗?

解决方案

问题出在你的方式上 串联的 变量。

您忘记了一个点和一个引号。改变 .$RegType" <br />;. $RegType . "<br />";

echo $index . "." . $preNAME . " " . $Name . " " . $RegType  "<br /> ;
                                                            ^  dot  ^ quote

将其更改为:

echo $index . "." . $preNAME . " " . $Name . " " . $RegType . "<br />";

您可以删除其中的空格 " " 如果你想。

其他提示

首先:您可以使用:

$tCompany_SQLselect_Query = mysql_query($tCompany_SQLselect) or die(mysql_error());
.

这将允许您调试错误。

第二:您可以使用:

$row = mysql_fetch_assoc($tCompany_SQLselect_Query)
.

缩短语法。

echo线应该是:

echo $index.".".$preNAME." ".$Name." ".$RegType." . "<br />";
.

您周围缺少<br />周围的引号,以及在它之前连接的.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top