Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP购物车内容打印输出_Php_Html_Sql_Postgresql_Xhtml - Fatal编程技术网

PHP购物车内容打印输出

PHP购物车内容打印输出,php,html,sql,postgresql,xhtml,Php,Html,Sql,Postgresql,Xhtml,我有一个简单的商店显示PostgreSQL数据库中的数据: $database = pg_connect("host= port= "); $query = 'SELECT * FROM table1 '; $query .= ' ORDER BY Price'; $result = pg_query($database, $query); echo '<form name="basket" action="basket.php" method="post">' . '<t

我有一个简单的商店显示PostgreSQL数据库中的数据:

$database  = pg_connect("host= port= ");
$query = 'SELECT * FROM table1 ';

$query .= ' ORDER BY Price';
$result = pg_query($database, $query);
echo '<form name="basket" action="basket.php" method="post">' . '<table border="1" class="center">';
echo "<tr></tr>";
while ($a = pg_fetch_row($result)) {
echo "<tr>";
echo "<td><input type='checkbox' name='games[]' value='.$id.' ></td>";
for ($j = 0; $j < pg_num_fields($result); $j++) {
    echo "<td>" . $a[$j] . "</td>";
}
echo "</tr>\n";
}
echo '</table>';
?>
<input type="submit" name="Add To Basket" value="Add To Basket" />
</form>
但这会产生以下结果:

array(4) { [0]=> string(2) ".." [1]=> string(2) ".." [2]=> string(2) ".." [3]=> string(2) ".." } Array ( [0] => .. [1] => .. [2] => .. [3] => .. )

有人能帮我吗谢谢你在字段值中添加了
,例如
value=“.7.”

echo”“;
^---^--

您也没有在任何地方定义
$id
,因此您正在输出一个未定义的变量,该变量将生成一个空白点。

复选框中没有
$id
值,添加为
$id=$a[0]

    while ($a = pg_fetch_row($result)) {
       $id = $a[0];
        echo "<tr>";
        echo "<td><input type='checkbox' name='games[]' value='$id' ></td>";
        for ($j = 0; $j < pg_num_fields($result); $j++) {
            echo "<td>" . $a[$j] . "</td>";
        }
        echo "</tr>\n";
    }
while($a=pg\u fetch\u row($result)){
$id=$a[0];
回声“;
回声“;
对于($j=0;$j
echo "<td><input type='checkbox' name='games[]' value='.$id.' ></td>";
                                                       ^---^--
    while ($a = pg_fetch_row($result)) {
       $id = $a[0];
        echo "<tr>";
        echo "<td><input type='checkbox' name='games[]' value='$id' ></td>";
        for ($j = 0; $j < pg_num_fields($result); $j++) {
            echo "<td>" . $a[$j] . "</td>";
        }
        echo "</tr>\n";
    }