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
https://forums.phpfreaks.com/topic/262321-php-display-elements/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.