Hello, I'm working on making a comment box. I'm currently testing out it with data that I entered into MySQL. The data does show on the page.
I have two problems:
- I don't know how to order my data by so that the data inside the ID1 section displays separately from ID2 section, for example:
ID2 name2
comment2[/QUOTE]
2. I'm also not sure on how to display the newest comments at the top, for example:
ID3 name3
comment3
ID2 name2
comment2
This is HTML/PHP code:
<?php
require("include/dbcomments.php");
// Comment ID
$ID = @mysql_query('SELECT ID FROM comments');
if (!$ID) {
die('<p>Error performing query: '.mysql_error().'</p>');
}
// Comment Date
$Date = @mysql_query('SELECT Date FROM comments');
if (!$Date) {
die('<p>Error performing query: '.mysql_error().'</p>');
}
// Comment Name
$Name = @mysql_query('SELECT Name FROM comments');
if (!$Name) {
die('<p>Error performing query: '.mysql_error().'</p>');
}
// Comment
$Comment = @mysql_query('SELECT Comment FROM comments');
if (!$Comment) {
die('<p>Error performing query: '.mysql_error().'</p>');
}
?>
<div id="all_comment">
<div id="ctitle">Comments</div>
<div id="csection">
<div id="infosection">
<span id="id">
<?php
while ( $row = mysql_fetch_array($ID) ) {
echo('<p>'.'#'.$row['ID'].' ');
}
?></span>
<span id="date">
<?php
while ( $row = mysql_fetch_array($Date) ) {
echo('Date: '.$row['Date'].' ');
}
?></span>
<span id="name">
<?php
while ( $row = mysql_fetch_array($Name) ) {
echo('Name: '.$row['Name'].'</p>');
}
?></span>
<div id="comment">
<?php
while ( $row = mysql_fetch_array($Comment) ) {
echo('<p>'.$row['Comment'].'</p>');
}
?>
</div><!--/infosection-->
</div><!--/csection-->
</div><!--/all_comment-->
Here is a screenshot of what I have so far:
http://img516.imageshack.us/img516/5527/59313250xa5.jpg
Any help would be great, thanks!