Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to show comments under a post like facebook does?
    primarykey
    data
    text
    <p>I'm trying to make a facebook wall-alike php script.</p> <p>It loads the posts stuff, photo url and user stuff like username and user id from my MySQL database. It also checks if the post is just a comment to another post (parentof). I can present all the original posts with pictures with a simple do-while using tags .</p> <p>But how could I present the comments under every post? I guess with another do-loop, but how?</p> <p>Here is my code:</p> <pre><code>&lt;?php require_once "config.php"; $result = mysql_query('SET NAMES utf8'); $result = mysql_query('SET CHARACTER SET utf8'); $wallhaku = mysql_query("SELECT `wall`.`post_id`, `wall`.`parentof`, `wall`.`sentby`, `wall`.`text`, `wall`.`image_url`, `users`.`username`, `users`.`photopath`, `users`.`name`, `users`.`member_id` FROM `wall` LEFT JOIN `users` ON `wall`.`sentby` = `users`.`member_id` WHERE parentof=0 ORDER BY post_id DESC") or die (mysql_error()); $row_wallhaku = mysql_fetch_array($wallhaku); &lt;table width="800" height="120" border="0" cellpadding="10"&gt; &lt;?php $i=0; $numberpage=1; do { $wallid = $row_wallhaku['post_id']; $parenthaku = mysql_query("SELECT post_id, parentof FROM wall WHERE parentof=$wallid") or die (mysql_error()); $row_parenthaku = mysql_num_rows($parenthaku); &lt;td width="120" align="left"&gt; &lt;img src=&lt;?php echo $row_wallhaku['photopath']; ?&gt; height= "100" width="100"&gt; &lt;/td&gt; &lt;td width="600" align="left"&gt; &lt;a href="member.php?id=&lt;?php echo $row_wallhaku['member_id']; ?&gt;"&gt;&lt;?php echo $row_wallhaku['name']?&gt;&lt;/a&gt;&lt;br /&gt;&lt;p&gt;&lt;?php echo $row_wallhaku['text']; if($row_wallhaku['image_url']=="0") { &lt;p align="right"&gt;&lt;?php echo $row_parenthaku ?&gt; kommenttia.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="post.php?id=&lt;?php echo $row_wallhaku['post_id']; ?&gt;"&gt;Lue, kommentoi&lt;/a&gt; &lt;?php } ?&gt;&lt;/td&gt; &lt;?php $i++; if($i%$numberpage==0) echo "&lt;/tr&gt;"; if($row_wallhaku['image_url']!="0") { &lt;tr&gt; &lt;td width='800' colspan='2' align='center'&gt; &lt;a href="post.php?id=&lt;?php echo $row_wallhaku['post_id']; ?&gt;"&gt;&lt;img src=&lt;?php echo $row_wallhaku['image_url']; ?&gt; height="180"&gt;&lt;/a&gt; &lt;p align="right"&gt;&lt;?php echo $row_parenthaku ?&gt; kommenttia.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="post.php?id=&lt;?php echo $row_wallhaku['post_id']; ?&gt;"&gt;Lue, kommentoi&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php } &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload