I am having a problem displaying data from a php page and outputting on a page in a div tag. can anyone help me. this is what i have done so far
HTML
include ('scripts/connect_to_db.php');
//Search the Database to check to see if the product in the database column matches the select product and order it by descending order
$lftresult = mysqli_query($conn,"SELECT distinct genre FROM video WHERE mediatype='".$cat."' GROUP BY genre");
while($leftrow = mysqli_fetch_array($lftresult))
{
$genre = $leftrow["genre"];
?>
<div class='left-choicediv'><!--specialoffer-divs-cols-->
<input type="button" class="cat" id="catlink" value="<?php echo $genre; ?>" onclick="sendcat(this.value);" />
<input type="hidden" name="cattype" id="cattype" value="<?php echo $cat; ?>" />
</div><!-- End of left-choicediv-->
<?php
}
?>
</div><!-- End of Left Column-->
<div class="right-column"><!-- Start of Right Column-->
<div id="rightcol"></div>
</div><!-- End of Right Column-->
JAVASCRIPT
function sendcat(elms)
{
if (window.XMLHttpRequest)
{
//Firefox, Opera, IE7, and other browsers will use the native object
var k = new XMLHttpRequest();
}
else
{
//IE 5 and 6 will use the ActiveX control
var k = new ActiveXObject("Microsoft.XMLHTTP");
}
var cattype = document.getElementById(cattype).value;
k.onreadystatechange = function()
{
if (k.readyState == 4 && k.status == 200)
{
document.getElementById("rightcol").innerHTML = k.responseText;
}
}
k.open("GET","sendcat.php?catchoice="+elms+"&cattype="+cattype,true);
// Send the data to PHP now... and wait for response to update the status div
k.send(null); // Actually execute the request
// document.getElementsByClassName("right-column").innerHTML = "images/loading/ajax-loader.gif";
}
PHP
<?php
include ('scripts/connect_to_db.php');
$cat = $_GET['catchoice'];
$cattype = $_GET['cattype'];
//If A user puts less than 5 exit
if (($cat == "all") || ($cat == ""))
{
$catchoices = mysqli_query($conn,"SELECT videoID,title,upload_path,thumb FROM video ORDER BY title")
or die(mysqli_error($conn));
}
//If A user puts more than 5 exit
else
{
$catchoices = mysqli_query($conn,"SELECT videoID,title,upload_path,thumb FROM video WHERE mediatype='".$cattype."' AND genre='".$cat."' ORDER BY title")
or die(mysqli_error($conn));
}
echo $catchoices;
$num_rows = mysqli_num_rows($catchoices);
echo "<h2>".$cat."</h2>";
if ($num_rows == 0)
{
echo "<p id='notfound'>There are no available</p>";
}
else
{
while($pdrows = mysqli_fetch_array($catchoices))
{
$vidid = $pdrows["videoID"];
$prdtitle = $pdrows["title"];
$upload_path = $pdrows["upload_path"];
$thumb = $pdrows["thumb"];
echo "<div class='product-divs'><!--product-divs-->";
echo "<h3>".$prdtitle."</h3>";
echo "<a href='product_details.php?vid=".$vidid."'><img src=".$upload_path.$thumb." alt='".$thumb."' border='0' /></a>";
echo "</div><!-- End of product-divs-->";
}
}
?>
I Don’t know where I’m Making a Mistake