loop within loop in PHP MySQL
I have created two tables in MySql one where blog content saved and another where blog ID and different pics path saved. I have saved more than one pics in one postID. Now I am trying to fetch the pics and blog post at same time but its not working. code below...
blogposts.php
<?php
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($conn,"SELECT * , upload_data.FILE_NAME from blog_posts LEFT JOIN upload_data ON blog_posts.postID=upload_data.postID ; ");
while($row = mysqli_fetch_array($result))
{?>
<div data-height="382">
<ul><?php
if (!empty($FILE_NAME)) {
$result = mysqli_query($conn,"SELECT * from upload_data where postID=postID ; ");
while($row = mysqli_fetch_array($result))
{?>
<li data-transition="3dcurtain-vertical" data-slotamount="12">
<img data-retina src="articles/user_data/<?php echo( htmlspecialchars( $row['FILE_NAME'] ) ); ?>">
</li> <?php }} ?>
</ul>
</div>
<div >
Title : <a href="#" ><?php echo( htmlspecialchars( $row['postTitle'] ) ); ?></a>, <a href="#" ><?php echo( htmlspecialchars( $row['postCat'] ) ); ?></a>
<span ></span>
Tag : <a href="#" >Nllam</a>
<span ></span>
<a href="#" ><i ></i>12 Comments</a>
</div>
<?php } ?>
The Problem is I am unable to fetch the pics. :(
Answer
Solution:
use this query
and then print your results with print_r() function and check its get results or not.
Answer
Solution:
Try like this you will get number of post rows and filename concadinated with commas if you have images. then Apply logic to display results. Any help you need. Don't hesitate to ask me.
Answer
Solution:
hope this work;