0

here is my problem : if I try to load a div outside the while loop (.testt) it works fine

$("#comment_area_"+n_comm_text).load("pages/userprofil.php .testt"); 

but if I use the same code to load a div inside the while loop it just make the #comment_area disappears :

$("#comment_area_"+n_comm_text).load("pages/userprofil.php comment_area_"+n_comm_text);

the while loop :

<?php 
$i=0;
while($row=mysqli_fetch_array($quser)){
$i++;?>
<div class="comment_area" id="comment_area_<?php echo($i);?>">
//some code
</div>
<?php } ?>

I hope my problem is clear , any help is very welcome . Thank you

7
  • You need to either end your PHP block before you write the HTML, or you need to echo the HTML within the PHP block. What you have above is mixing them together and will not work.
    – Patrick Q
    Nov 7, 2016 at 16:51
  • Missing # for #comment_area... : .load("pages/userprofil.php #comment_area_"+n_comm_text);
    – fdomn-m
    Nov 7, 2016 at 16:54
  • Check your rendered html without the php hieroglpyhs
    – fdomn-m
    Nov 7, 2016 at 16:56
  • no , just because I tried to write a minature of my code here , I forgot to mention the Php blocks , may you please reCheck my post , I've just edited it Nov 7, 2016 at 17:06
  • @freedomn-m thank you that was a good remark , but still doesn't work Nov 7, 2016 at 17:07

1 Answer 1

0

in your while loop, make sure to separate HTML from PHP. Pay special attention to quotes and double quotes, and how to concatenate strings with variables. Hope it helps.

$i=0;
while($row=mysqli_fetch_array($quser)){
$i++;
echo '<div class="comment_area" id="comment_area_'.$i.'">';
//some code
echo '</div>';
}
3
  • I edited my code , may you please check again my post Nov 7, 2016 at 17:05
  • Echo variables without parentheses, see that you have <?php echo($i);?> instead of <?php echo $i; ?>. If the divs aren't showing at all on your HTML, the issue comes from the loop. But you also need to check freedomn-m's answer regarding the hash. Nov 7, 2016 at 17:13
  • yeah still the same problem . Thank you anyway ;) Nov 8, 2016 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.