there are currently three posts but when onclick alerts only one post.If I echo the posts insite the loop,then all three posts are shown,however if I alert them,then onlyone posts is show.plz help or suggest any alternative approach.
$sql=mysqli_query($db3,"SELECT * from user where id='$id'");
$num_rows=mysqli_num_rows($sql);
while($row=mysqli_fetch_array($sql)){
$posts=$row['posts'];
}
?>
<span onclick=u(<?php echo $posts; ?>)> <?php echo $num_rows ?> </span>
<script type="text/javascript">
function u(posts) {
alert(posts);
}
</script>
<?php
Update
Here is second query After using the array approach ,If i use fancy box with $num rows to show all posts in the fancybox .I am again getting the only one result on the fancybox.Plz help
$posts[] = $row['posts'];
} foreach ($posts as $af){
echo "<div id='#modelbox_id'>$af</div>";}
?>
<a href="#modelbox_id" class="modelbox"><?php echo $num_rows; ?></a>
<?php