Hello All,
Is it possible to evaluate one query within a while loop of another query.
Below is my code which shows all the data from the database to html.
now inside the while loop, i want some more info from another table. i tries it with code(the highlited one), but when i use it only one result is shown on html.
<?php
$displayList = "";
$sql = "SELECT * FROM forum_sections ORDER BY ordered ASC LIMIT 20";
$query=mysqli_query($db_conx,$sql);
$blogcount = mysqli_num_rows($query);
if($blogcount<1){
$result="You havenot posted any Blog yet,Post one now.";
}
else{?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Buddies Column-One Place</title>
<link rel="stylesheet" type="text/css" href="css/mystyling.css">
<link rel="icon" href="css/pictures/logo.png" type="image/x-icon">
<style type="text/css">
#blogdata {
width:75%;
border:2px solid silver;
background-image:url('css/images/yell.jpg');
background-size:cover;
font-weight:bolder;
text-align:center;
overflow:hidden;
padding:3px;
margin:auto;
}
</style>
</head>
<body>
<div id="bloggy" style=" min-height:550px; background-size:cover;" >
<div id="blogdata">
<?php
while($row = mysqli_fetch_array($query, MYSQLI_ASSOC)){
$sectionID = $row["id"];
$sectionTitle = $row["title"];
$displayList= '<a href="newsection.php?id=' . $sectionID . '"><img src='.$thumb.' width="100%" height="150" alt="Section" /></a>';
$sectionTitle='<a href="newsection.php?id=' . $sectionID . '">'.$sectionTitle.'</a>';
[COLOR="#00FF00"]$sql = "SELECT DISTINCT otid FROM forum_posts WHERE section_title='$sectionTitle'";
$query=mysqli_query($db_conx,$sql);[/COLOR]
?>
<div class="img-wrap"><p class="title"><?php echo $sectionTitle;?></p><div class="imge"><?php echo $displayList;?></div></div>
<?php
}
}
?><br/><br/>
</div><!---blogdata--->
</div><!---end of bloggy-->
</body>
</html>