为什么“数量”值不显示任何值?

神奇骑士

我正在尝试显示数据库表中的“数量”值,但未$quantity在浏览器中显示该值。为什么?

在此处输入图片说明

<?php

include('connection.php');

# cartexe.php will perform all actions on cart.php

// add Item to Cart
if(isset($_POST['addItemToCart']))
{
    // initialize index.php variables
    $productName = $_POST['productName'];
    $price = $_POST['price'];
    $description = $_POST['description'];
    $quantity = 0;

    // check the cart table to see if the product has been previously added
    $smtp = $conn->prepare('SELECT * FROM cart WHERE Product_Name = :product'); // prepare a statement to fetch the quanity for a particular pprodut... the statement is not executed but merely prepared to do so. 
    $smtp->bindParam(':product', $productName, PDO::PARAM_STR); //bind the productNAme with whatever data supplied hence the statement after : above will be replaced with the actually data.. In additional the statement is set as string hence PDO::PRAM_STR
    $smtp->execute();//finally run the statment

    //var_dump($smtp);
    //find the number of rows affected
    $result = $smtp->fetch(PDO::FETCH_NUM);
    // var_dump($smtp);


    //the data does existed
    if($result > 0)
    {
        $row = $smtp->fetch(PDO::FETCH_ASSOC);
        echo " DATA FOUND";
        echo $row['Quantity'];

        //$quantity++; // increment the quanity if data found
     }
     //no match found
     else
     {
         echo ' No data found';
     }

 }

 ?>
博扬

似乎您不需要先尝试获取

$smtp = $conn->prepare('SELECT * FROM cart WHERE Product_Name = :product'); // prepare a statement to fetch the quanity for a particular pprodut... the statement is not executed but merely prepared to do so. 
    $smtp->bindParam(':product', $productName, PDO::PARAM_STR); //bind the productNAme with whatever data supplied hence the statement after : above will be replaced with the actually data.. In additional the statement is set as string hence PDO::PRAM_STR
   ;//finally run the statment



    //the data does existed
    if( $smtp->execute() )
    {
        $row = $smtp->fetch(PDO::FETCH_ASSOC);
        echo " DATA FOUND";
        echo $row['Quantity'];

        //$quantity++; // increment the quanity if data found
     }

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

为什么字段值不显示?

来自分类Dev

ModelChoiceForm不显示任何值

来自分类Dev

RecycleView 不显示任何值

来自分类Dev

显示块,不显示任何选项值

来自分类Dev

为什么我的argparse不显示默认值?

来自分类Dev

为什么我的单元格值不显示?

来自分类Dev

为什么输出不显示初始化值-1?

来自分类Dev

XSL为什么不显示任何数据

来自分类Dev

ng-repeat不显示任何值

来自分类Dev

Google BigQuery:为什么由不同表的并集产生的表在预览模式下不显示任何值?运行查询时只有它吗?

来自分类Dev

为什么Html.DisplayFor显示模型属性名称而不显示属性值?

来自分类Dev

VIM为什么显示Unicode代码点而不显示UTF-8代码值?

来自分类Dev

当数量大于1时不显示NULL值

来自分类Dev

为什么并行堆栈不显示任何任务?

来自分类Dev

为什么ng-include不显示任何内容?

来自分类Dev

为什么ng-bind-html不显示任何内容?

来自分类Dev

为什么我的Logcat不显示任何日志?

来自分类Dev

为什么我的策略不显示任何数据?

来自分类Dev

为什么使用分组时ListView不显示任何内容?

来自分类Dev

为什么我的硒代码不显示任何文本?

来自分类Dev

为什么此C ++程序不显示任何输出?

来自分类Dev

为什么git branch不显示任何内容?

来自分类Dev

为什么散景散布图不显示任何内容?

来自分类Dev

为什么我的Logcat不显示任何日志?

来自分类Dev

为什么我的以下程序不显示任何输出(ArrayList)?

来自分类Dev

为什么 vis.js 不显示任何内容

来自分类Dev

任何想法为什么我的 FileUpload 不显示文件?

来自分类Dev

为什么我的 recyclerView 不显示任何数据?

来自分类Dev

为什么我的 Toast.makeText 不显示任何内容

Related 相关文章

热门标签

归档