0
嘿工作在一个小项目,但我似乎有我的代码的特定部分的问题。问题与数组空白回声
第一部分精美地工作,并在产品类别中显示产品。 http://mkiddr.com/phptests/shopping/category.php?id=2
但是,问题似乎是要显示的类别描述,它是从一个单独的查询派生到它自己的数组中。我已经使用了
echo(mysqli_num_rows($result2));
这似乎是从查询中计算正确的行数,表明SQL正在完美工作。
我很感谢这方面的帮助我是一个完整的需求,我已经修补并编辑了这个代码以满足我的需求(由大学提供)。 P.S我知道有安全漏洞。
<?php
session_start();
include "conn.php";
include "header.php";
if (isset($_GET['id'])){
$CategoryID = $_GET['id'];
$q="SELECT ProductID, ProductName FROM Products WHERE CategoryID=$CategoryID";
$d="SELECT `Desc` FROM ProductCategories WHERE CategoryID=$CategoryID";
$result = mysqli_query($_SESSION['conn'],$q);
$result2 = mysqli_query($_SESSION['conn'],$d) or die(mysql_error());
echo "<div>";
while ($row = mysqli_fetch_row($result)){
echo "<p><a href='product.php?id=".$row[0]."'>".$row[1]."</a></p>";
}
echo "</div>";
mysqli_free_result($result);
//Description
echo(mysqli_num_rows($result2)); //Test SQL
echo "<div>";
while ($myResult = mysqli_fetch_assoc($result2)){
echo "<p>".$myResult[0]."</p>";
}
echo "</div>";
}
include "footer.php";
?>
太棒了!你已经解决了,非常感谢。 – 2013-03-07 18:49:13