How to display contents from mysql database in Order?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashfaqbinnazar
    New Member
    • Apr 2010
    • 5

    How to display contents from mysql database in Order?

    This is a part of a Social community that i am going to build in php.
    This is same as the My friend list frame in Orkut,facebook etc.
    how can i display the content in mysql database order by 3 colums and 3 rows.
    Please help me...
    Thanks in advance.
    here is my code of my friends frame
    userreg is the table name
    id<>$id means-select all id of users except the logged persons id.

    Code:
    My Friends</h3>
            <table width="29%"  height="277" border="1">
            <?php $result= mysql_query("SELECT * FROM userreg where id<>'$id'")
    				or die(mysql_error());  
      				$count3=mysql_num_rows($result);
    				while($count3>0)
    				{
    				$count3--;
    				$row4= mysql_fetch_array($result);
    				$y=$row4['username']; 
    				$id=$row4['id']; 
    				$toid=$id;
    				?>
                   <tr>
                     <td height="89">&nbsp;</td>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                   </tr>
                   <tr>
                     <td height="89">&nbsp;</td>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                   </tr>
                   <tr>
    			<td width="35%" height="89">
                <?php 
    			echo "<a href='scrapbook.php?toid=$toid'>$y</a>";
    			?>			</td>
                <td width="33%">&nbsp;</td>
                <td width="32%">&nbsp;</td>
              </tr>
              <?php }?>
    </table>
    Last edited by Dormilich; Apr 29 '10, 07:25 AM. Reason: Please use [code] tags when posting code
  • chathura86
    New Member
    • May 2007
    • 227

    #2
    you can use mysql ORDER BY to sort the result set

    search for MySQL ORDER BY in google to get some idea about it

    Regards

    Comment

    • ashfaqbinnazar
      New Member
      • Apr 2010
      • 5

      #3
      Thanks alot for the information..

      Comment

      Working...