How to display messages from mysql database in rows?

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

    How to display messages from mysql database in rows?

    Dear friends,
    How can i display messages from mysql database in each rows with delete and reply button.
    Thanks in advance.
    Here is my code.
    i have created a page like scrapbook.
    and splitted the scrapbook into two,ie my scrapbook and my friends scrapbook.
    $toid is active only when i visit others profile.
    if $toid is blank then display my scrqapbook otherwise my friend scrapbook.
    Code:
    <td><table width="100%" height="99" border="1">
                 <?php 
                    if($toid=="" or $toid==$id)
    				{
    				$rst = mysql_query("SELECT * FROM messages where toid='$id' ORDER BY id DESC")
    				or die(mysql_error());  
      				$count=mysql_num_rows($rst);
    				while($count>0)
    				{
    				$count--;
    				$row = mysql_fetch_array($rst);
    				 $delid=$row['id'];
    			     $x=$row['msg'];
    				  $from=$row['fromid'];
    				  $row7=fromname($from);
    				 $fromname=$row7['username'];
    				 $row4=userdata($id);
    				 ?>
    			    <?php 
    				  echo "<table width='100%' border='1'>
    				  <tr>
    				  <td width='10%'><a href='scrapbook.php?toid=$from'>$fromname</a></td> 
    				  <td width='75%'>$x<br>
    				  <input name='delete' type='submit' id='delete' value='Delete'>
    				 <input name='reply' type='submit' id='reply' value='Reply'>
    				  </td>
    				  </tr>
    				  </table>";
    				  $delid=$row['id'];
    				   $delete_query = "DELETE FROM messages WHERE id = '$delid'";
    					if($delete){
    					mysql_query($delete_query) or die(mysql_error());
    					}
    				  $msg="Done";}} 
    				else
    				{
    				$id=$toid;
    				{
    				$rst3 = mysql_query("SELECT * FROM messages where toid='$id' ORDER BY id DESC")
    				or die(mysql_error());  
      				$count2=mysql_num_rows($rst3);
    				while($count2>0)
    				{
    				$count2--;
    				$row3 = mysql_fetch_array($rst3);
    				 $delid2=$row['id'];
    			     $y=$row3['msg']; 
    				 $from=$row3['fromid'];
    				 $row6=fromname($from);
    				 $fromname=$row6['username'];
    				 echo "<table width='100%' height='109' border='1'>
    				  <tr valign='bottom'><td width='14%' height='103'>$fromname</td> 
    				  <td valign='top' width='86%'>$y</td>
    				  </tr></table>";
    				  }}}?></table>
          *</td>
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    Where are you stuck?
    Which line of the code isn't working?

    I can't write the entire code for you. I can help yo answer /specific/ questions.

    Let us know,





    Dan

    Comment

    Working...