Jump to content

PHP Display Elements


RedHat

Recommended Posts

Hello mates,

I'm newbie in PHP and I'm trying to make something here. I'm working on a script that allows me to write some comments (from admin panel) and display them on my index page. For now, the script is displaying me all comments that I'm writing, and I want to display just 5 let's say.

 

Any solution for this?

 

 <tbody>
                <?php
                $scom=mysql_query("select * from comments order by date desc");
                $num=mysql_num_rows($scom);

                if($num!=0) {
                
                while($randc=mysql_fetch_array($scom))
                {
               echo'   <tr>
                    <td width="50" align="center" valign="top" bgcolor="#B5D2DC"><img src="images/500999.png" width="30" height="30" /></td>
                    <td class="textmic">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#B5D2DC">
                      <tr>
                        <td class="textc"><u>'.$randc["date"].'</u></td>
                      </tr>
                      <tr>
                        <td align="justify">';
                    $newtext = wordwrap($randc["comment"], 20, "\n", true); 
                        echo $newtext.'</td>
                      </tr>
                      <tr>
                      <td>
                       <hr width="100%" noshade="noshade" size="8" color="#B5D2DC" />
                      </td>
                      </tr>
                    </table>
                    </td>
                  </tr>
                 ';
                }
                }
                  ?>
                  
                  </tbody>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.