首页 \ 问答 \ 而循环不按预期循环(while loop not cycling through as expected)

而循环不按预期循环(while loop not cycling through as expected)

我有一个循环,它运行MySQL查询返回的行并执行命令。

当数据显示在网页上时(在粘贴代码的末尾看到),requested_date(来自$ result_dec查询)正在循环,但memPayout(来自$ emailcompleted查询)不是。 在显示memPayout的地方,它只列出了每个日期的相同数字。

当我在phpmyadmin中运行它时,我看到不同的日期有不同的memPayouts ..所以我知道这里有一个错误。

我很感激帮助。

更新:我已经用我调整过的新代码更新了旧代码。 我试图用最初的foreach包装电子邮件收入查询。 我还删除了不必要的额外bgcolor开关。 我网页上的结果仍然与以前相同。 任何更多的建议真的很感激。

<?php                           
//--------------------- Code for Decline TRANSACTION --------------------------------------
$u_id = $_SESSION['user_ses']['id'];

$result_dec = @mysql_query("(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal ,  trv.requested_date, trv.requested_status, trv.click_payment_status, trv.tracking_id
from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr
where t.id=trv.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and trv.payment_status='pending' and trv.requested_status='declined'  group by trv.tr_user_id, trv.requested_date order by trv.requested_date asc )
union all
(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.click_request_date, trv.requested_status, trv.click_payment_status, trv.tracking_id
from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr
where t.id=trv.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and trv.payment_status='pending' and trv.click_payment_status='declined'  group by trv.tr_user_id, trv.click_request_date order by trv.requested_date asc ) ");
    $nr = mysql_num_rows($result_dec);
    $categories_d = array();
    while($row = mysql_fetch_array($result_dec))
    { 
            $categories_d[] = $row;
    }

    if(count($categories_d)>0)
    {
        $counter=0;
        foreach($categories_d as $index=>$rec)
        {
            $counter++;
            if ($counter % 2 == 0)
            {
                    $bgcolor = "#FFFFFF";
            }
            else
            {
                    $bgcolor = "#F5F7D9";
            }



        $userId=$rec['tr_user_id'];

  $EmailCompletedOffer=@mysql_query("select off.member_amount as memPayout
                        from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr 
                        where t.id=trv.tracking_id  and off.id=t.offer_id and  off.offer_type='mailchimp' and  usr.id=trv.tr_user_id and 
                        trv.tr_user_id=$userId and trv.requested_date='".$requested_date."' and trv.payment_status='pending' and trv.total_conversion !=0 and trv.requested_status='declined' ");
                        $rowemailEarn=@mysql_fetch_array($EmailCompletedOffer);
                        $totalEmailEarnAmount1=$rowemailEarn['memPayout'];

?>
                        <div class="datarow_his">
                            <div class="his_onecol1"><?php echo '$'. $totalEmailEarnAmount1;?> </div>
                            <div class="his_onecol1"> <?php echo "Declined"; ?> </div>
                            <div class="his_onecol2"><?php echo date("M j,Y " ,strtotime($rec['requested_date']));?></div>
                            <!--<div class="his_onecol1"><?php //echo date("M j,Y " ,strtotime($rec['paid_date']));?></div>-->
                        </div> 
                        <p><?php echo $totalEmailEarnAmount1?></p>
<?php                    /*}
                    } */




        } 
    } 

?>

I have a loop that runs through returned rows from a MySQL query and performs commands.

When the data is displayed on the webpage (seen at the end of the pasted code), the requested_date (from the $result_dec query) is cycling through correctly, but the memPayout(from the $emailcompleted query) is not. Where it shows the memPayout it is just listing the same number for each date.

When I run this in phpmyadmin, I see that different dates have different memPayouts..so I know there is a bug here.

I appreciate the help.

UPDATE: I've updated the old code with the new one that I adjusted. I tried to wrap the email earnings query with the original foreach. I also removed the unnecessary extra bgcolor switch. The result on my webpage is still the same as before. Any more advice is really appreciated.

<?php                           
//--------------------- Code for Decline TRANSACTION --------------------------------------
$u_id = $_SESSION['user_ses']['id'];

$result_dec = @mysql_query("(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal ,  trv.requested_date, trv.requested_status, trv.click_payment_status, trv.tracking_id
from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr
where t.id=trv.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and trv.payment_status='pending' and trv.requested_status='declined'  group by trv.tr_user_id, trv.requested_date order by trv.requested_date asc )
union all
(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.click_request_date, trv.requested_status, trv.click_payment_status, trv.tracking_id
from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr
where t.id=trv.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and trv.payment_status='pending' and trv.click_payment_status='declined'  group by trv.tr_user_id, trv.click_request_date order by trv.requested_date asc ) ");
    $nr = mysql_num_rows($result_dec);
    $categories_d = array();
    while($row = mysql_fetch_array($result_dec))
    { 
            $categories_d[] = $row;
    }

    if(count($categories_d)>0)
    {
        $counter=0;
        foreach($categories_d as $index=>$rec)
        {
            $counter++;
            if ($counter % 2 == 0)
            {
                    $bgcolor = "#FFFFFF";
            }
            else
            {
                    $bgcolor = "#F5F7D9";
            }



        $userId=$rec['tr_user_id'];

  $EmailCompletedOffer=@mysql_query("select off.member_amount as memPayout
                        from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr 
                        where t.id=trv.tracking_id  and off.id=t.offer_id and  off.offer_type='mailchimp' and  usr.id=trv.tr_user_id and 
                        trv.tr_user_id=$userId and trv.requested_date='".$requested_date."' and trv.payment_status='pending' and trv.total_conversion !=0 and trv.requested_status='declined' ");
                        $rowemailEarn=@mysql_fetch_array($EmailCompletedOffer);
                        $totalEmailEarnAmount1=$rowemailEarn['memPayout'];

?>
                        <div class="datarow_his">
                            <div class="his_onecol1"><?php echo '$'. $totalEmailEarnAmount1;?> </div>
                            <div class="his_onecol1"> <?php echo "Declined"; ?> </div>
                            <div class="his_onecol2"><?php echo date("M j,Y " ,strtotime($rec['requested_date']));?></div>
                            <!--<div class="his_onecol1"><?php //echo date("M j,Y " ,strtotime($rec['paid_date']));?></div>-->
                        </div> 
                        <p><?php echo $totalEmailEarnAmount1?></p>
<?php                    /*}
                    } */




        } 
    } 

?>

原文:https://stackoverflow.com/questions/21311663
更新时间:2023-08-28 11:08

最满意答案

为什么不使用您的Web服务器作为接口,它创建相应的公钥和私钥,并将其用于加密和解密? 确保您甚至加密将b / w服务器发送到应用程序的密钥加密的方式。


Why not use your web server as a interface, which creates the corresponding public and private key, and uses it for encryption and decryption? Make sure you even encrypt the way the keys which are sent b/w server to application are encrypted.

相关问答

更多
  • 3 ^ 54是58149737003040059690390169.它会导致溢出,因此您应该实现模块化指数化 ,因为我不太了解JavaScript,所以我已经编写了应该很容易在javascript中实现的ac代码: int power(int a, int b, int prime){ int result; if(b == 0){ result = 1; }else if(b == 1){ result = a % prime ...
  • 别。 如果您需要在生产代码中解决此类问题,请让专家来做。 密码学中存在许多微妙的陷阱,你很可能会成为一个收割者。 Don't. If you need to solve this kind of problem in production code, have an expert do it. There are so many subtle pitfalls in cryptography that chances are you will come a cropper.
  • 是。 如果 g ^ a mod p = g ^ x mod p 然后 g ^ ab mod p = g ^ xb mod p 尤其是 (g ^ b mod p)^ a mod p =(g ^ b mod p)^ x mod p 因此,出于所有实际目的,您可以假装Alice的私钥是x。 这就是为什么g成为组的生成器很重要的原因,因此没有这样的'兄弟'私钥。 她不知道'原始'a,但她确实知道它是(通常)一小组数字与x不同的o(g)的倍数。 它是哪一个并不重要。 在这种特殊情况下,发生的是g是296而不是592 ...
  • 问题是g.pow(secret)是一个真正的,非常非常大的数字。 它比p大得多,并且有大约的secret数字。 如果你将secret增加到普通Diffie-Hellman秘密指数的范围内(与p的数字大约相同),那么你的计算机将没有足够的内存来保存它。 地球上的所有计算机都没有足够的内存来容纳它。 这是一个非常大的数字。 但是g.pow(secret).mod(p) - 你想要的最终答案 - 只有大约和p一样多的数字,所以它是计算机跟踪的易处理数字。 这只是一个太大而无法处理的中间值。 所以你需要利用像这样的 ...
  • Crypto ++网站建议使用最小p为3072位(或ECC实现的256位)来传输128位AES密钥。 您可能希望研究http://www.keylength.com/en/compare/上提供的参考资料,以获取有关比较不同算法之间密钥长度的更多信息。 The Crypto++ website suggests using a minimum p of 3072 bits (or 256 bits for an ECC implementation) to transport a 128 bit AES k ...
  • 为什么不使用您的Web服务器作为接口,它创建相应的公钥和私钥,并将其用于加密和解密? 确保您甚至加密将b / w服务器发送到应用程序的密钥加密的方式。 Why not use your web server as a interface, which creates the corresponding public and private key, and uses it for encryption and decryption? Make sure you even encrypt the way th ...
  • 你忘了两个模数: >>> 5556302616191343498765890791686005349041729624255239232159744 % 22 16L >>> 793714773254144 % 22 16 You forgot two more modulos: >>> 5556302616191343498765890791686005349041729624255239232159744 % 22 16L >>> 793714773254144 % 22 16
  • 您的bcopy更换是错误的。 两者中的第三个参数是长度,另外两个是交换的,所以:#define bcopy(a,b,c)memcpy(b,a,c) Your bcopy replacement is wrong. The third parameter in both is length, the other two are swapped, so do: #define bcopy(a, b, c) memcpy(b, a, c)
  • 显而易见的解决方案是使用WCF建立SSL或TLS连接,而不是尝试将其构建到应用程序中。 The obvious solution would be to use WCF to establish an SSL or TLS connection instead of attempting to build that into the application.
  • 它可能比两个复杂一点。 考虑一个有N个人的循环。 每个编号为1,2,3,..., N 。 他们共享相同的P和G. 每个人都有自己的一个号码。 现在每个人都为自己计算G a ,并将结果发送给下一个。 然后每个人计算出值G 1 a ,其中G 1是前一个人给出的值。 重复该过程N次,每个人都有相同的数字G N = G a 1 a 2 ... a N. 伪代码: import G, P from public generate a send pair{pow(G, a, P), 1} to next person ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)