如何从数据库中的一行中提取单个值并将其放入HTML标记中, 我的代码看起来像这样,
<?php
$projectName = strval($_GET['project']);
$thicknessValue = intval($_GET['thicknessValue']);
$baseplateValue = strval($_GET['baseplateValue']);
$query = "SELECT QTY_REQUIRED FROM COMPONENT_CUTTING
WHERE THICKNESS = :thicknessVal
AND PROJECT_NAME = :projectName
AND BASE_PLATE = :baseplateVal
AND REQUEST_STATUS = 'OPEN'";
$result = oci_parse($conn, $query);
oci_bind_by_name($result, ":projectName", $projectName);
oci_bind_by_name($result, ":thicknessVal", $thicknessValue);
oci_bind_by_name($result, ":baseplateVal", $baseplateValue);
oci_execute($result);
?>
<?php
while($row = oci_fetch_num($result, OCI_NUM)) { ?>
<input type="number" name="quantityToCut" min="0" max="<?php echo $row[QTY_REQUIRED] ?>" type="text" value="">
<?php } ?>
错误显示如下,
致命错误:在第44行的C:\ xampp \ htdocs \ WeltesInformationCenter \ Component_request \ findQuantity.php中调用未定义的函数oci_fetch_num()
答案 0 :(得分:3)
因此。那oci_fetch_num
应该是什么意思呢?正确的方法是oci_fetch_array
while($row = oci_fetch_array($result, OCI_NUM))
菲尔指出如果你使用OCI_NUM作为获取模式,那么你必须使用数字索引。你可以简单地做
while($row = oci_fetch_array($result)) // Numeric and Associative both indices
答案 1 :(得分:2)
在while中使用oci_fetch_array
,并执行<?php echo $row[0] ?>