为什么while循环不能正常工作,请帮助 [英] Why the while loop is not working correctly, need assistance please

查看:92
本文介绍了为什么while循环不能正常工作,请帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 store_credits_order 表和订单表。



我希望输出类似于这个



到目前为止我尝试过的代码是:



I have a store_credits_order table and orders table.

I want the output to be similar to this.

The code that I have tried so far is:

<?php
$table = '';
$queryToGetStoreCredit = "SELECT * FROM store_credits_orders WHERE SCO_CustEmailAdd = '".$_SESSION["Customer"]["email"]."'";
$validate->Query($queryToGetStoreCredit);
if ($validate->NumRows() >= 1) {
    while ($rows_sco = $validate->FetchAllDatas()) {
        $used = $i = 0;
        $table .= '<tr>';
        $table .= '<td>'.$rows_sco["SCO_OrderCode"].'</td>';
        $table .= '<td>--</td>';
        $table .= '<td>'.$rows_sco["SCO_OrderDate"].'</td>';
        $table .= '<td>--</td>';
        $table .= '<td>'.$rows_sco["SCO_Purchase_Amount"].'</td>';
        $table .= '<td>'.$rows_sco["SCO_Credit_Alloted"].'</td>';
        $table .= '<td>'.$used.'</td>';
        $table .= '<td>'.( $rows_sco["SCO_Credit_Alloted"] - $used ).'</td>';
        $table .= '</tr>';

        $validate2 = new Validation("benef8w7_ecommerce");
        $queryToGetOrder = "SELECT * FROM orders WHERE CustEmailAdd = '".$rows_sco["SCO_CustEmailAdd"]."'";
        $validate2->Query($queryToGetOrder);
        while ($row = $validate2->FetchAllDatas()) {
            $table .= '<tr>';
            $table .= '<td>--</td>';
            $table .= '<td>'.$row["OrderCode"].'</td>';
            $table .= '<td>--</td>';
            $table .= '<td>'.$row["OrderDate"].'</td>';
            $table .= '<td>--</td>';
            $table .= '<td>--</td>';
            $table .= '<td>'.$row["AppliedCredits"].'</td>';
            $table .= '<td>'.($rows_sco["SCO_Credit_Alloted"] - $row["AppliedCredits"]).'</td>';
            $table .= '</tr>';
        }
    }
}
?>





我想要实现的是,只要购买store_credits,信息就会插入store_credits_orders表中。现在,当同一个用户来时,下订单并兑换store_credits(小于等于,他在他的帐户中),除了在orders表中插入之外,数据库中不会有更新。但是当用户登录时,他应该能够看到我何时购买了store_credits和/或他已经兑换了store_credits。无论购买或兑换,所有这些活动都应该按照先发生的事件进行订购。



我不知道我缺少哪里。请帮助我解决这个问题,因为我在2天后就已经摸不着头脑了。



非常感谢任何帮助。



谢谢。



What I want to achieve is, whenever there is a purchase of store_credits, the information will get inserted in the store_credits_orders table. Now when the same user comes, places an order and redeems the store_credits (less than equal to, he has in his account), there will no update in the database other than insertion in the orders table. But when the user logs in, he should be able to see when I he has purchased the store_credits and/or when he has redeemed the store_credits. All these events should be ordered by whichever event happens first, irrespective of purchase or redeem.

I don't know where am I lacking. Kindly help me with this as I am scratching my head since 2 days to achieve this.

Any help is highly appreciated.

Thanks.

推荐答案

table = ' ';
table = '';


queryToGetStoreCredit = SELECT * FROM store_credits_orders WHERE SCO_CustEmailAdd ='
queryToGetStoreCredit = "SELECT * FROM store_credits_orders WHERE SCO_CustEmailAdd = '".


_SESSION [ 客户] [ email]。< span class =code-string> ';
_SESSION["Customer"]["email"]."'";


这篇关于为什么while循环不能正常工作,请帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆