如何查看数据库中任何特定项目的详细信息?

时间:2013-07-23 05:02:33

标签: php html mysql database

我正在创建一个程序,向用户显示产品列表,当用户点击任何特定产品时,它会打开产品,用户可以查看该特定产品的详细信息。我编写了以下代码,但它没有显示任何输出。如果我看到地址栏看起来它的工作正常,但在浏览器中它既没有显示任何输出也没有任何错误。

  

地址栏localhost / cms / single_product.php?product_id = 25

请指导我。

由于

<?php
session_start();
//$id= $_SESSION['id'];
$id= $_GET['product_id'];

    include 'connect.php';


        $query= "select * from products, product_description where products.product_id=$id 
                    and product_description.product_id=$id";


        echo "<a href='update_single_product.php?product_id=$id' > Update Product</a>";

            if ($query_run=mysql_query($query))
                {
                    $fetch=     mysql_fetch_array($query_run);



                    //print_r ( $fetch['product_id']);      

                    echo $fetch['name'];
                    echo $fetch['description'];
                    echo $fetch['item_no'];
                    echo $fetch['recipient'];       


                }

            else
                {

                echo mysql_error();
                        }



?>

1 个答案:

答案 0 :(得分:0)

试试这个

SELECT products.*,product_description.* FROM products
INNER JOIN product_description
ON (products.product_id=$id AND product_description.product_id=$id)
this will work definitely