473,503 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to display messages from mysql database in rows?

5 New Member
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.
Expand|Select|Wrap|Line Numbers
  1. <td><table width="100%" height="99" border="1">
  2.              <?php 
  3.                 if($toid=="" or $toid==$id)
  4.                 {
  5.                 $rst = mysql_query("SELECT * FROM messages where toid='$id' ORDER BY id DESC")
  6.                 or die(mysql_error());  
  7.                   $count=mysql_num_rows($rst);
  8.                 while($count>0)
  9.                 {
  10.                 $count--;
  11.                 $row = mysql_fetch_array($rst);
  12.                  $delid=$row['id'];
  13.                  $x=$row['msg'];
  14.                   $from=$row['fromid'];
  15.                   $row7=fromname($from);
  16.                  $fromname=$row7['username'];
  17.                  $row4=userdata($id);
  18.                  ?>
  19.                 <?php 
  20.                   echo "<table width='100%' border='1'>
  21.                   <tr>
  22.                   <td width='10%'><a href='scrapbook.php?toid=$from'>$fromname</a></td> 
  23.                   <td width='75%'>$x<br>
  24.                   <input name='delete' type='submit' id='delete' value='Delete'>
  25.                  <input name='reply' type='submit' id='reply' value='Reply'>
  26.                   </td>
  27.                   </tr>
  28.                   </table>";
  29.                   $delid=$row['id'];
  30.                    $delete_query = "DELETE FROM messages WHERE id = '$delid'";
  31.                     if($delete){
  32.                     mysql_query($delete_query) or die(mysql_error());
  33.                     }
  34.                   $msg="Done";}} 
  35.                 else
  36.                 {
  37.                 $id=$toid;
  38.                 {
  39.                 $rst3 = mysql_query("SELECT * FROM messages where toid='$id' ORDER BY id DESC")
  40.                 or die(mysql_error());  
  41.                   $count2=mysql_num_rows($rst3);
  42.                 while($count2>0)
  43.                 {
  44.                 $count2--;
  45.                 $row3 = mysql_fetch_array($rst3);
  46.                  $delid2=$row['id'];
  47.                  $y=$row3['msg']; 
  48.                  $from=$row3['fromid'];
  49.                  $row6=fromname($from);
  50.                  $fromname=$row6['username'];
  51.                  echo "<table width='100%' height='109' border='1'>
  52.                   <tr valign='bottom'><td width='14%' height='103'>$fromname</td> 
  53.                   <td valign='top' width='86%'>$y</td>
  54.                   </tr></table>";
  55.                   }}}?></table>
  56.       *</td>
  57.  
Apr 30 '10 #1
1 1600
dlite922
1,584 Recognized Expert Top Contributor
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
May 6 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

51
3718
by: w_curtis | last post by:
I'm an Access user, and I'm trying to learn MySQL and then PHP so I can make some web databases. But it just isn't clicking. I've followed some tutorials, and picked up a book, but just getting...
0
1424
by: LRW | last post by:
I manage our mySQL database through putty (SSH terminal client). And whenever I do a select * from the table that contains ENCODEd passwords, the funky characters do funky things with the display....
0
3925
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
2
9895
by: Gnurp Gnarp | last post by:
When the number of columns get large, it becomes increasingly difficult to view the results of a select in a small window (e.g. 80 line xterm) because of line wrapping. Can I have the results of...
2
1886
by: moller | last post by:
Im looking in to the possibility of moving from mySQL to an access database. My reasons are: (1) Database is single user. (2) Database local on users PC. (3) Database has only 8 tables where 4...
2
4350
by: ameshkin | last post by:
I know this is probably not too hard to do, but how do I display multiple rows of a mysql query/recordset. Im having trouble doing this. I don't just want to display them, but I want to make sure...
2
7035
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
6
38451
Atli
by: Atli | last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users. Anyone should be able to get...
10
2700
by: darkenroyce | last post by:
Hi Guys I am creating a sports database and one of the features involves create drop down dialogue boxes that retrieve data from MySQL tables and provides them as <option> within...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4688
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3168
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.