简体   繁体   中英

Extracting single value from the DB ORACLE

How do i extract the single value from one row in the database and put it in the HTML tag, my code looks like this,

<?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 } ?>

the error shows like this ,

Fatal error: Call to undefined function oci_fetch_num() in C:\\xampp\\htdocs\\WeltesInformationCenter\\Component_request\\findQuantity.php on line 44

So. what oci_fetch_num is supposed to mean then? The correct method is oci_fetch_array

while($row = oci_fetch_array($result, OCI_NUM)) 

As Phil pointed out if you use OCI_NUM as fetch mode then you have to use numeric indexes. You could simply do

while($row = oci_fetch_array($result))      // Numeric and Associative both indices

在一段时间内使用oci_fetch_array ,然后执行<?php echo $row[0] ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM