简体   繁体   English

如果满足声明条件但仍无法识别

[英]If Statement condition not being recognised despite being met

I have an if statement where the condition compares a session variable to the value 0 and if met, echo's a message. 我有一个if语句,其中条件将会话变量与值0进行比较,如果满足,则返回一条消息。 If not, it prints a table of data. 如果不是,它将打印数据表。 The problem is that the condition, despite being met, is not being recognised. 问题在于,尽管满足了条件,但仍无法识别。 I have tested to make sure that the value of the session variable is being set and it is. 我已进行测试,以确保正在设置会话变量的值。 It is used elsewhere on the page and definitely has a value set. 它在页面上的其他地方使用,并且绝对有一个值集。 Any idea's what might be wrong here? 知道这里有什么问题吗?

*EDIT: There is a session start function at the beginning of the page. *编辑:在页面的开头有一个会话开始功能。

<?php//if number of rows returned is none
        if($_SESSION["CART_NUM"] == 0){
        echo 'YOU HAVE NO ITEMS IN YOUR CART';
        }else{
    //else display cart items
    ?>

        <table id="cart">
            <tbody>
                <tr>
                    <td><h6>ITEM NAME</h6></td>
                    <td><h6>QTY</h6></td>
                    <td><h6>PRICE</h6></td>
                    <td><h6>TOTAL</h6></td>
                    <td><h6>DELETE</h6></td>
                </tr>
<?php
                //query DB again for cart items matching cust id
                $custcart = oci_parse($conn,"SELECT * FROM   
                A113222813_CARTLINE WHERE CUST_ID= :cust_id");
                oci_bind_by_name($custcart, ":cust_id", $_SESSION["CUST_ID"]);
                oci_execute($custcart);

                while ($row = oci_fetch_array($custcart, OCI_ASSOC)) {?>

                <tr class="cartvals">
                    <td><p><?php echo $row['CART_NAME']; ?></p></td>
                    <td><p><?php echo $row['PRICE']; ?></p></td>
                    <!--Form for updating quantity-->
                    <td><form class="updateform" method="post" id="form<?php echo $row['CART_ID'];?>" action="updatecart.php?id=<?php echo $row['CART_ID']; ?>">
                            <input type="text" name="qty" value="<?php echo $row['CART_QTY']; ?>">
                            <a href="javascript:{}" onclick="document.getElementById('form<?php echo $row['CART_ID']; ?>').submit();">submit</a>
                        </form>
                    </td>
                    <td><p><?php echo '&euro;' . ($row['CART_QTY'] * $row['PRICE'])  ?></p></td>
                    <!--Appends cart_id as query string param. Deleteitem.php will get this as an id and delete corresponding row.-->
                    <td><a href="deleteitem.php?item=<?php echo   
                    $row['CART_ID']?>">DELETE</a></td>
                </tr>
<?php
}?>
            </tbody>
        </table>
    </div><!--End Cart Table-->
</div><!--End Main Content-->
<?php

oci_close($conn);
?> 

SOLVED: 解决了:

The line <?php//if number of rows returned is none had the comment touching the tag. <?php//if number of rows returned is none使注释触及标签。 Spaced it's working again. 隔开它再次工作。

Thanks for taking a look anyway! 无论如何,感谢您的关注!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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