Working on a small university project to develop a small php site. Seem to be having a couple of issues. I am a complete newbe when it comes to programming of any kind. I am literately cutting and pasting (From provided scripts) and trying to get things to come together in the way I require.
I seem to be having a problem collecting data from a database query, I already have one on the script which works perfectly. I am trying to add another, however can't seem to get this to work.
http://mkiddr.com/phptests/shopping/category.php?id=2
Currently the category.php is displaying all the products within the category. However I wish for it to also display the category description and you'll see in the following code how I've tried to do this:
<?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);
echo "<div>";
while ($row = mysqli_fetch_row($result)){
echo "<p><a href='product.php?id=".$row[0]."'>".$row[1]."</a></p>";
}
echo "<p>".$result2."</p>";
echo "</div>";
mysqli_free_result($result);
}
include "footer.php";
?>
Would appreciate some help!
UPDATED CODE (Still not working)
<?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);
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 "<div>";
while ($result2 = mysqli_fetch_assoc($result2)){
echo "<p>".$result2[0]."</p>";
}
}
include "footer.php";
?>