| View previous topic :: View next topic |
| Author |
Message |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun May 04, 2008 8:51 pm Post subject: [SOLVED]More PHP help - Tables |
|
|
http://pastebin.com/m4e7f6da7
Yeah, well this is the problem:
Everytime, say, there is a new message, it does not create a new row in the table, it creates another table.. Which i do not want...
I want one subject/message after another. Which is not working. Please help.
_________________
Last edited by Localhost on Sun May 04, 2008 9:24 pm; edited 1 time in total |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun May 04, 2008 9:10 pm Post subject: |
|
|
| Code: |
while($row = mysql_fetch_array($result))
{
// From, Subject, Message, Date //
echo "<table border='1'>";
echo "<tr>";
echo "<td>From</td>";
echo "<td>Subject</td>";
echo "<td>Message</td>";
echo "<td>Date</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $row['from'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['message'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "</tr>";
echo "</table>";
} |
You need to take the table echos out and only echo the <tr> / <td> sections inside the loop.
_________________
- Retired. |
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun May 04, 2008 9:15 pm Post subject: |
|
|
I am not understanding what you are saying :\
Take the echos out of what exactly?
And why?
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sun May 04, 2008 9:19 pm Post subject: |
|
|
You said you don't want it to create a new table for each post, but instead, just enter the post into the table. You are echoing out a new table inside the while.
| Code: | while($row = mysql_fetch_array($result))
{
// From, Subject, Message, Date //
echo "<table border='1'>";
//.. other table shit in here ..
echo "</table>";
} |
Notice the <table> </table> in there? Thats why you are getting new tables for each post. Move them outside the loop
| Code: | echo "<table border='1'>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>From</td>";
echo "<td>Subject</td>";
echo "<td>Message</td>";
echo "<td>Date</td>";
echo "</tr>";
echo "<tr>";
echo "<td>" . $row['from'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['message'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "</tr>";
}
echo "</table>"; |
_________________
- Retired. |
|
| Back to top |
|
 |
Localhost I post too much
Reputation: 0
Joined: 28 Apr 2007 Posts: 3402
|
Posted: Sun May 04, 2008 9:24 pm Post subject: |
|
|
So close But i got it now!
That made it so it didnt make a new table, but it still kept on making From, Subject, ect
So i just moved From,Subject ect out and now it works
| Code: |
echo "<table border='1'>";
echo "<tr>";
echo "<td>From</td>";
echo "<td>Subject</td>";
echo "<td>Message</td>";
echo "<td>Date</td>";
echo "</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['from'] . "</td>";
echo "<td>" . $row['subject'] . "</td>";
echo "<td>" . $row['message'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "</tr>";
}
echo "</table>";
|
Thanks
_________________
|
|
| Back to top |
|
 |
|