我正在尝试显示数据库中已有的数据,我将这些数据传递到这样的表中
<?php
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result)){
var_dump($row);
//echo $last_id;
'<tr>
<td> ' . $row['ord_id'].'</td>
<td> '.$row['ord_total'].'</td>
<td> '.$row['ord_date'].'</td>
<td> '.$row['ord_qty'].'</td>
<td> '.$row['card_id'].'</td>
<td> '.$row['card_price'].'</td>
<td> '.$row['card_field1'].'</td>
<td> '.$row['card_field2'].'</td>
<td> '.$row['card_field3'].'</td>
<td> '.$row['card_field4'].'</td>
<td> '.$row['card_field5'].'</td>
</tr>';
var_dump($row);
}
?>
我在几个地方使用了 var_dump($row) 它返回数据,但该数据未显示在表中
最佳答案
我不太确定你想做什么,但我认为你想设置 last_id
至$_SESSION
然后用它 cart.php
,如果我是对的,你必须更改你的product.php代码并设置 $_SESSION['last_id']
在通过 header()
重定向之前,像这样:
if (mysqli_query($con, $insert))
{
$last_id = mysqli_insert_id($con);
$_SESSION['last_id'] = $last_id; // check this row
echo '<script>alert("Order added to cart")</script>';
header("Location: ../neo/cart.php");
}
else
{
echo "Error: " . $insert . "<br>" . mysqli_error($con);
}
}
}
$last_id = $_SESSION['last_id'];
关于php - 我试图显示数据库中的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58153654/