php - 如何查看order_number中的所有记录

标签 php mysql

function view_amshops_order_details()
{
  session_start();
  if($_SESSION['UserId']<=0)
  {
    signin();
  }

  //here fetch your signup form for session//

  $rs2=mysql_query("select *from user where u_id='$_SESSION[UserId]'");
  $data2=mysql_fetch_assoc($rs2);
  $smarty=new smarty();
  $smarty->assign($data2);

  global $View_Path; 
  $i=0;
  $amshops=mysql_query("select * from payment_amshops join order_amshops on payment_om_id=om_id join delivery_address on om_dl_id=dl_id join payment_status on payment_status_id = status_id WHERE payment_om_id=om_id AND payment_u_id='$_SESSION[UserId]'");

  $records=array();
  $smarty->assign(array("act"=>"view_amshops_order_details"));
  while($detail=mysql_fetch_assoc($amshops))
  {

        $order_number=$detail['om_order_number'];
        $detail['size']=strlen($i);
        array_push($records,$detail);
        //$inner_records=array();
        $inner_amshops=mysql_query("select * from addtocart_2 join category2 on cart_cg_id=cg_id where cart_cg_id=cg_id AND order_number='$order_number'");
        while($inner_detail=mysql_fetch_assoc($inner_amshops))
        {
            if($inner_detail[cg_pic]!='')$file=$View_Path.$inner_detail[cg_pic];
            if(!file_exists($Upload_Path.$inner_detail[cg_pic]))$file='';

            array_push($records[$i],$inner_detail);

        }
        //$detail['size']=$i+1;
        //array_push($records[0],$i);

        $i++;

  }
//  echo "<pre>";
//  print_r($records);
//  exit;

  $smarty->assign(array("records"=>$records, "file"=>$file));
  $smarty->display("templates/view_amshops_order_details_2.tpl");
}




 and my tpl file 

 {foreach $records as $detail}
    <table class="table table-responsive" style="border:solid #BBBBBB 1px;">


    <thead>
    <tr bgcolor="#E8E8E8">
    <td colspan="4" align="left" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <a href="#" class="btn btn-primary">OrderID -&nbsp;{$detail.om_order_number}</a></td>
    <td colspan="4" align="center">&nbsp;
    <a href="#" class="btn btn-success"><b>&nbsp;&nbsp;Payment&nbsp;-&nbsp;{$detail.status_name}&nbsp;&nbsp;</b></a>
    </td>
    </tr>
    </thead>

    {for $i=0 to $detail['size']}
    {if $detail[$i].order_number}
    <tbody>
    <tr >

    <td><br />
    <a href="index.php?act=bigview_men_cloth&cg_id={urlencode(base64_encode($detail[$i].cg_id))}">
    <img src="admin_panel/images/category/{$detail[$i].cg_pic}" class="img-thumbnail" style="width:50px;; height:70px;"/>
    </a>
    </td>

    <td align="left"><br />
    {$detail[$i].cg_name}&nbsp;{$detail[$i].cg_type}<br />
    {if $detail[$i].cart_size}Size:&nbsp;{$detail[$i].cart_size}{else}{/if}
    <br />
    Seller:&nbsp;{$detail[$i].cg_seller}
    </td>
    <td align="left"><br />&nbsp;{$detail[$i].cart_size}</td>
    <td align="left"><br />Rs.&nbsp;{$detail[$i].cart_total}</td>
    <td align="left"><br />&nbsp;{$detail[$i].cg_dldetail}</td> 
    <td align="left"><br />&nbsp;</b><br /><br /><br /><br /></td>
    </tr>
    </tbody>
    {/if}
    {/for}

    <thead>
    <tr bgcolor="#F5F5F5">
    <td colspan="4" align="left" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    </td>
    <td colspan="4">&nbsp;
    <a href="#" class="btn btn-danger"><b>&nbsp;&nbsp;Order Total&nbsp;:&nbsp;Rs.&nbsp;{$detail.om_price}&nbsp;&nbsp;</b></a>
    </td>
    </tr>
    </thead>

    </table>
    {/foreach}

我想要喜欢我网站上的 filpcart 订单详细信息页面,但我遇到了一些问题.....我在一个 order_number 中有四条记录,当我查看所有记录时,只查看其中的两条记录order_number...请帮助我...

最佳答案

<?php
function view_amshops_order_details(){
    session_start();
        if(!$_SESSION['UserId'])//If session doesnt exist call signin
        {
            signin(); //No signin function on this page nor is it included
        }

    $userId = $_SESSION['UserId'];

    $conn = new mysqli('host', 'username', 'password', 'databaseName');

    $rs2 = $conn->query("SELECT field,field FROM user WHERE u_id='$userId'");
    $rs2Row = $rs2->fetch_assoc();
    // then use $rs2Row['tableName'];
    global $View_Path;
    $i=0;

    $amshops = $conn->query("SELECT field,field,field from payment_amshops join order_amshops WHERE payment_om_id=om_id and payment_u_id='$userId'"); //Shouldnt be any reason that you would have to join the same two tables over and over so this should clear it up a bit
    if(mysqli_num_rows($amshops) > 0){
        while($row = $amshops->fetch_assoc()) {
            $order_number = $row['om_order_number'];
            $row['size'] = strlen($i); // Not sure why you want this to be done considering you are calling the data from your db and then changing it. "$detail['size']=strlen($i);"

        }
    } else {
        echo('Database came back with no results');
    }
    $inner_amshops = $conn->query("SELECT field,field,field FROM addtocart_2 join category2 WHERE cart_cg_id=cg_id AND order_number='$order_number'");
    if(mysqli_num_rows($inner_amshops) > 0){
        while($row = $inner_amshops->fetch_assoc()) {
            if(!$row['cg_pic']){
                $file=$View_Path.$row['cg_pic'];
            }
            if(!file_exists($Upload_Path.$row['cg_pic'])){
                $file = "";
            }
        }
    }
    //Suggest rewriting html to get rid of smarty completly it seems because I highly recommend that you learn to carry data over echo();

关于php - 如何查看order_number中的所有记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41542321/

相关文章:

php - 如何检查数组的某个部分是否存在于另一个数组中?

php - 使用 Eval 函数时无法捕获异常

php - 有谁知道这个 php 错误消息背后的含义吗?

php - 数据库登录失败,Mysql、html、php

php - 使用 php 将用户引导到另一个页面

php - 条件 PHP/Javascript 表单元素

sql - 优化使用 between 子句的 SQL

php - 创建固定长度的可索引非重复组合

Mysql数据转换

php - 使用 INSERT 语句时出现 HTTPS 500 错误