Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/241.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么无法在“添加到购物车”中获取该值_Php - Fatal编程技术网

Php 为什么无法在“添加到购物车”中获取该值

Php 为什么无法在“添加到购物车”中获取该值,php,Php,这里是food.php的页面,它将链接到order.php以将订单添加到购物车中 <input type="hidden" name="id" value="<?php echo $row["foodID"];?>" /> <dt> <img src="<?php echo $row["food_img"];?>" /> <input name="img"

这里是food.php的页面,它将链接到order.php以将订单添加到购物车中

<input type="hidden" name="id" value="<?php echo $row["foodID"];?>" />
            <dt>
            <img src="<?php echo  $row["food_img"];?>" />
            <input name="img"  type="hidden" class="img" value="<?php echo  $row["food_img"];?>" /> </dt>
            <dd>

         <form action="order.php" method="get" name="send" onSubmit="return Check()"  enctype="multipart/form-data">
                <h3><?php echo  $row["food_name"];?>
                <input name="name"  type="hidden" class="name" value="<?php echo  $row["food_name"];?>" /></h3>
                <div class="detailtips">
                    <?php echo  $row["food_description"];?>
                </div>
                <p><span>Restaurant:</span><strong><?php echo  $row["restaurant_name"];?>
                <input name="restaurant"  type="hidden" class="restaurant" value="<?php echo  $row["restaurant_name"];?>" />
                </strong></p>
                <p><span>Type :</span><strong><?php echo  $row["food_type"];?></strong></p>

                <input name="num"  type="hidden" class="num" value="<?php echo  $row["order_num"];?>" />

                <p><span>Price :</span>RM &nbsp;<strong><?php echo  $row["food_price"];?>
                <input name="price"  type="hidden" class="price" value="<?php echo  $row["food_price"];?>" /></strong></p>

                <div class="order" style=" padding-top:20px; padding-left:20px;">
                <input name="" type="submit"  value="" class="ordersubmit" style=" margin-left:30px; margin-top:20px;">
                </div>
                </form>

肚子

尝试删除标题(“内容类型:text/html;charset=utf-8”);来自order.php。我想,因为你发送的是标题,所以你的$GET被清除了。删除后,它仍然是一样的,无法从食物中获取任何数据。php你的url包含$GET数据?我的url获取以下内容:order.php?name=Smokehouse+Bacon+Cheese+Burger&restaurant=Morganfield%27s&num=0&price=28.90它可以获取食物名称、餐厅名称、订单编号,食品价格和你想要的是通过order.php传递$GET[“id”]?不同的食品有不同的foodID,当点击提交按钮时,它将链接到order.php,其中包含来自food.php的所有$GET信息,并且你已经测试过order.php通过$GETnope接收这些数据,无法获取数据…..food.php基于$foodID=$\u GET['id']成功地从数据库获取数据;我把它放在html的底部,将食品订单添加到购物车中,但我不知道order.php为什么不能从food.php获取数据
<?php session_start();  
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');
header("Content-type: text/html; charset=utf-8"); 
include("conn.php");

$action = $_GET['action'];
$user = $_SESSION['username'];
foreach ($_GET AS $key=>$value)
{
$key ;
}
$nameid=substr($key,4);
$namenum=$_GET[$key];
if($namenum){
    $arr = mysql_query("select * from  ordering  where id='$nameid'");
    $rowres = mysql_fetch_array($arr);
    $total=$rowres['food_price']*$namenum;
    $sqlup="update ordering SET  order_num='$namenum', total='$total' where id='$nameid'" ;
    $rus = mysql_query($sqlup);
  }
  if(empty($user)){
  echo "<script>alert('No login, please log in!');window.location='Log In.php';</script>";
  exit;
  }
  $orderID = $_GET['id'];
  $food_img = $_GET['img'];
  $food_name = $_GET['name'];
  $restaurant_name = $_GET['restaurant'];
  $food_price = $_GET['price'];
  $order_num = $_GET['num'];

  $total=$food_price*$order_num;
  if($action == 'add'){

   $arr = mysql_query("select * from  ordering  where id='$orderID'");
    $rowres = mysql_fetch_array($arr);

    $row=mysql_num_rows($arr);   
  if($row>0){$ordernum=$rowres['order_num']; 
      $t_price=$rowres['food_price'];
         $ordernum=$ordernum+$order_num;
                $t_pricea=$t_price*$ordernum;
            $sql="update ordering set order_num='$ordernum', total='$t_pricea' where id='$orderID' ";
             $resulta = mysql_query($sql);
                if($resulta==true)
  {
   echo "<script>alert('success');window.location.href='order.php'</script>";
  }
  }else{

    $sqlin="INSERT INTO ordering (`id`,`orderID`,`food_img`,`food_name`,`restaurant_name`,`food_price`,`total`,`order_num`,`username`,`time`)  VALUES('','$orderID','$food_img','$food_name','$restaurant_name','$food_price','$total','$order_num','$user',now()) ";
    $rus = mysql_query($sqlin);
       if($rus==true)
  {
   echo "<script>alert('success');window.location.href='order.php'</script>";
  }

      } 

  }

  ?>
  <?PHP 
  if($action=="delcar"){
  $delid=$_POST['delcar'];
  $pieces = explode(",", $delid); 
  if($pieces==""){
            echo "<script language=\"javascript\">alert('please choose!');window.location.href='order.php'</script>";die;

      }
   $arrayLen = sizeof( $pieces );
   for( $i = 0; $i< $arrayLen ;$i++ )
   {
   $sql="delete from  ordering where id='$pieces[$i]'";    

   $result=mysql_query($sql);  }
   if($result==true)
   {
   echo "<script language=\"javascript\">alert('del  success!');window.location.href='order.php'</script>";die;
   }else{
    echo "<script language=\"javascript\">alert('del  failed, please re-enter!');window.location.href='order.php'</script>";die;
   }    

   }
   ?>
   <div class="shopbox">
    <form method="get" action="orderlist.php" id="shopcarall" >
    <input type="hidden" name="action" value="change" />

 <div class="shopmain">

<ul><li style="padding:30px 10px 0 0"><input name="chackcar[]" type="checkbox"  class="userid"  value="<?php echo $row['id']?>" /></li>
      <li class="boxa"> <img src="<?php echo $row['food_img'];?>" width="130" height="98"> </li>
      <li class="boxb">
    <h3>Food name</h3>
    <h4><?php echo $row['food_name'];?> </h4>
  </li>
   <li class="boxc">
    <h3>Restaurant</h3>
    <h4> <?php echo $row['restaurant_name']; ?> </h4>
  </li>
      <li class="boxc">
    <h3>Food  price</h3>
    <h4> <?php echo $row['food_price']; ?> </h4>
  </li>
      <li class="boxc">
    <h3>Order  num</h3>

       <h4>

         <a class="del" href="javascript:void(0)"> - </a><input type="text" name="<?php echo $row['id']; ?>" class="inputcss" value="<?php echo $row['order_num']; ?>" style=" margin:0; float:left">
        <a class="add" href="javascript:void(0)"> + </a>
        </h4>

  </li>
      <li class="boxc">
    <h3>Total</h3>
    <h4>RM <?php echo $row['total'];?></h4>
  </li>
    </ul>


            </div>
    </form>
<?php 
session_start();  
ini_set('error_reporting', 'E_ALL ^ E_NOTICE');
header("Content-type: text/html; charset=utf-8"); 
include("conn.php");
$foodID = $_GET['id'];
$arr = mysql_query("select * from foodmenu where foodID=$foodID");
$result = mysql_fetch_array($arr);

?>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Tumy</title>
<link rel="stylesheet" href="css/foodcart.css">
</head>

<body>
<div class="headerwrapper">
<div id="header" class="container">
    <div class="logo"> <a href="homepage.php"><img src="image/LOGO.png" alt="logo" width="165" height="74"></a> </div>
    <nav>
        <ul id="navigations">
            <li><a href="homepage.php">HOME</a></li>
            <li> <a href="restaurant.php">RESTAURANT</a></li>
            <li><a href="rating.php">CUSTOMER FEEDBACK</a></li>
            <li><a href="userprofile.php">USER PROFILE</a></li>
            <li><a href="logout.php">LOGOUT</a></li>
        </ul>

    <a href="order.php"><img src="image/cart.png" width="50" height="50"></a>
    </nav>
  </div>
</div>


<div class="indexbox"> 
    <?php    

        $result = mysql_query("SELECT * FROM foodmenu where foodID = '$foodID'"); 
        while($row=mysql_fetch_array($result)){
             ?>
<div class="detailback">
    <a href="restaurant.php">Restaurant</a><span>&gt;</span><?php echo $row["restaurant_name"];?><span>&gt;</span>
    <button onClick="goBack()" style="background-color:#F00; border:solid;">Food Menu</button>
    <script> function goBack(){
            window.history.back();
    }</script>
</div> 
<div class="detail">
    <div class="detailtop">

        <dl>
        <input type="hidden" name="id" value="<?php echo $row["foodID"];?>" />
            <dt>
            <img src="<?php echo  $row["food_img"];?>" />
            <input name="img"  type="hidden" class="img" value="<?php echo  $row["food_img"];?>" /> </dt>
            <dd>

         <form action="order.php" method="get" name="send" onSubmit="return Check()"  enctype="multipart/form-data">
                <h3><?php echo  $row["food_name"];?>
                <input name="name"  type="hidden" class="name" value="<?php echo  $row["food_name"];?>" /></h3>
                <div class="detailtips">
                    <?php echo  $row["food_description"];?>
                </div>
                <p><span>Restaurant:</span><strong><?php echo  $row["restaurant_name"];?>
                <input name="restaurant"  type="hidden" class="restaurant" value="<?php echo  $row["restaurant_name"];?>" />
                </strong></p>
                <p><span>Type :</span><strong><?php echo  $row["food_type"];?></strong></p>

                <input name="num"  type="hidden" class="num" value="<?php echo  $row["order_num"];?>" />

                <p><span>Price :</span>RM &nbsp;<strong><?php echo  $row["food_price"];?>
                <input name="price"  type="hidden" class="price" value="<?php echo  $row["food_price"];?>" /></strong></p>

                <div class="order" style=" padding-top:20px; padding-left:20px;">
                <input name="" type="submit"  value="" class="ordersubmit" style=" margin-left:30px; margin-top:20px;">
                </div>
                </form>
            </dd>
        </dl>
        <?php }?>
  </div>
 </div>
</div>


<div class="copyrightswrapper">
<div id="copyrights" class="container">

   <p>&copy; TUMY - All Rights Reserved.</p>

</div> 
</div>

</body>
</html>