如何根据产品ID访问页面

时间:2015-04-27 08:24:09

标签: javascript php html

我在从一个页面导航到另一个页面时遇到问题。

<?php
 while($row = mysqli_fetch_array($result)) { ?>
                 <div class="list">
                <p><a href="Commodities.php?v=<?php echo $row['idproducts'] ?>"><?php echo $row['productname']?></a></p>
                <div class="images">
                       <img src="<?php echo  'images/'. $row['image']  ?>" style="max-width:100%;height:auto;" />
                    </div>
                }
            <div class="text">
              <p>
                   <?php echo $row['description'] ?>
              </p>
            </div>
            <div class="clear"></div>

        </div>
<?php

问题在于,当我点击产品链接时,它没有进入所需的产品描述页面。而不是将其重定向到相同的商品页面。所以我不明白该怎么做。所以请帮我找出我的错误..

2 个答案:

答案 0 :(得分:3)

您错过了标记内的php标记。请看一下更新的代码

 <?php while ($row = mysqli_fetch_array($result)) { ?>
    <div class="list">
        <p><a href="Commodities.php?v=<?php echo $row['idproducts']; ?>"><?php echo $row['productname']; ?></a></p>
        <div class="images">
            <img src="<?php echo 'images/' . $row['image']; ?>" style="max-width:100%;height:auto;" />
        </div>
          <!-- remove this end curly braces from ur markup-->
        <div class="text">
         <p>
                <?php echo $row['description']; ?>
        </p>
    </div>
    <div class="clear"></div>
</div>
<?php } ?>
<!-- close while loop in proper place. as of now $row['description'] outside from while loop -->

答案 1 :(得分:0)

php语句中的语法错误..

回声语句不以(;)

终止
<?php
 while($row = mysqli_fetch_array($result)) { ?>
             <div class="list">


        <p><a href="Commodities.php?v=<?php echo $row['idproducts']; ?>"><?php echo $row['productname']; ?></a></p>


         <div class="images">

                <img src="<?php echo  'images/'. $row['image']; ?>" style="max-width:100%;height:auto;" />

            </div>

        <div class="text">

             <p>

            <?php echo $row['description']; ?>
        </p>
        </div>
       <div class="clear"></div>

    </div>   
  <?php }?>
 <?php