dpdt79577 2014-12-13 11:34
浏览 27
已采纳

如何根据来自其他页面的数据放置页面内容

I have a page (menu.php) that retrieves and displays data from a database including name, image, price I want to add a link when i click on the image take me to another page (single Product.php) , so i have only one page and i want its content depending on the image i have clicked

    <div class="row">
    <div class="col-md-9">
    <div class="products-heading">
        <h2>Our Salad</h2>
    </div>  <!-- End of /.Products-heading -->
    <div class="product-grid">
    <div class="row">
            <?php
                require('connection.php');
                extract($_POST);

                $rc=mysql_query("select * from menu where Item_Catagory = 'Salad'") or die(mysql_error());
                while($MenuItem=mysql_fetch_array($rc))
                {

                ?>
                <!--To send item info to single-product page -->

                <div class="col-md-4">
                <div class="products">

                        <a href="single-product.php" >
                            <img src="images/<?php echo $MenuItem['Item_Image']; ?>"  alt="" />
                        </a>
                        <a href="single-product.php">
                            <h4> <?php echo $MenuItem['Item_Name']?> </h4>
                        </a>
                        <p class="price"> <?php echo $MenuItem['Item_Price']?></p>
                        <div class="row lead">
                            <center><div id="stars" class="starrr"></div></center>
                        </div>
                        <a class="view-link shutter" href="#">
                            <i class="fa fa-plus-circle"></i>Add To Cart</a>
                    </div>  <!-- End of /.products -->
                </div> <!-- End Of /.Col-md-4 -->    

        <?php }

        ?>

    </div>  <!-- End of /.row -->

this is a part of the first page I want to use get method to send the data to the another page, but i do not what is the appropriate method should i use javascript?if yes how?

  • 写回答

2条回答 默认 最新

  • douyu7210 2014-12-13 11:41
    关注

    Use id's to send data:

    <a class="view-link shutter" href="Product.php?id="<?= $MenuItem['id'];?>">

    In the other page $dataID = $_GET[id]; than query your DB where id=$dataID

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站