PHP MYSQL 查询 连接到别页

_Chen_ 发布于 2013/11/04 15:40
阅读 228
收藏 1

我想要做一个从订单查询里面的订单点进去,就会连接到那个订单的详细内容

但是我从订单查询那边点进去后,详细订单除了订单编号有出来,其他都是空白的

不知道是不是有哪边写错?

谢谢

订单查询:

<?php
$db = mysql_connect("localhost", "root", "root");
mysql_query("SET NAMES 'UTF8'");
mysql_select_db("opencart"); // 
$sql = "SELECT order.order_id, order.date_added, order.total, order.payment_method, order_status.name FROM `order` NATURAL JOIN order_status";
$rows = mysql_query($sql); 
$num = mysql_num_rows($rows); 
mysql_close($db);
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <link rel="stylesheet" href="jquery.mobile.min.css">
        <script src="jquery-1.10.1.min.js"></script>
        <script src="jquery.mobile.min.js"></script>
    </head>
    <body>
<div data-role="page" id="_order">
  <div data-role="header">
  <h1>订单查询</h1>
  </div>
  <div data-role="content">
     <ul data-role="listview" data-inset="true">

        <?php
        if ($num > 0) { 
          for ($i = 0;$i < $num; $i++ ) {
            $id = mysql_result($rows, $i, "order_id");
			$date_added = mysql_result($rows, $i, "date_added");
			$total = mysql_result($rows, $i, "total");
			$payment_method = mysql_result($rows, $i, "payment_method");
			$name = mysql_result($rows, $i, "name");
            echo "<li>";
            echo "<a href='order.php?order_id=" . $id . "'>";
            echo "<p>" . "订单编号 : ",$id . "</p>";
            echo "<p>" . "购买时间 : ",$date_added . "</p>";
            echo "<p>" . "金额 : ",$total . "</p>";
            echo "<p>" . "付款方式 : ",$payment_method . "</p>";
            echo "<p>" . "订单状态 : ",$name . "</p>";
            echo "</a></li>";
          }
        }
        ?>

     </ul>
	 
  </div>

</div>
    </body>
</html>

详细订单:


<?php
$id = $_GET["order_id"]; 
$db = mysql_connect("localhost", "root", "root");
mysql_query("SET NAMES 'UTF8'");
mysql_select_db("opencart"); 
$sql = "SELECT order.order_id, order.email, order.payment_firstname, order.payment_lastname, order.telephone, order.payment_method, order.shipping_firstname, order.shipping_lastname, order.shipping_address_1, order.total, order.date_added, order_product.name, order_product.quantity, order_product.price, order_product.total, order_status.name FROM `order` NATURAL JOIN order_status JOIN order_product  ON order.order_id=order_product.order_id WHERE order_id='" . $id . "'";
$rows = mysql_query($sql); 
$row = mysql_fetch_row($rows);
mysql_close($db); 
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title></title>
        <link rel="stylesheet" href="jquery.mobile.min.css">
        <script src="jquery-1.10.1.min.js"></script>
        <script src="jquery.mobile.min.js"></script>
    </head>
	    <body>
<div data-role="page" id="order">
  <div data-role="header">
  <h1>订单明细</h1>
  </div>
  <div data-role="content">
     <ul data-role="listview" data-inset="true">

            <li>订单编号 : <?echo $id?> </li>
            <li>E-MAIL:<?echo $row[1]?> </li>
            <li>姓名:<?echo $row[2]?> </li>

          
        
     </ul>
  </div>
</div>
    </body>
</html>


加载中
0
铂金小狗
铂金小狗

你这代码,不知道是跟着哪位大神的书敲出来的!~~

如果id的数值传过去了,那么就成功了!~~

0
悲催不悲催
悲催不悲催

02 $id = $_GET["order_id"];

这个$id有值吗?这是看谁的书敲的?

0
_Chen_
_Chen_
这代码是之前在网路上看到某位大神贴的,但是我忘了在哪看的了
id值应该是有传过去吧?因为我的订单编号有出来
$id= $ _GET ["order_id"] 这应该是从订单查询那边$id连过来的吧?


0
wx---每日佳选
wx---每日佳选
检查mysql  日志。
返回顶部
顶部