Jump to content

Archived

This topic is now archived and is closed to further replies.

pocobueno1388

How would you make a bumping system? *Still needs help*

Recommended Posts

I have coded a forum script which pretty much works just like this one on PHPfreaks. The only thing I am not sure on is how to make it to where if somone posts a reply on a board, the topic will be 'bumped' up to the top of the page...

I have no idea where to start on this one, so you may have to explain in detail, lol.

Thanks XD

Share this post


Link to post
Share on other sites
Well, I have never really gotten into forum software yet (seems I'm always coding a website or other project), so I'm not sure this is necessarily the 'best' way to go. However, this is how I would do it.

I am going to assume you already have a topic table and a post table. It not, you'd better set that stuff up beforehand. :P

Anyway, in your topic table, create a column called 'last_post' (or something like that). Then, in your script... whenever someone adds a new post, make it update the last_post column for the specified row in the topics table with the current time.

EDIT: Then, in your topic listing script (where it lists all the topics for the specified category/forum), instead of ordering them by ID or whatever, order them by last_post (descending of course). :)

Share this post


Link to post
Share on other sites
Oh wow, that would work great. Thanks for your help.

If anyone else has any other suggestions, please list them. Although, I think Woolf's idea would get the job done just fine XD

Share this post


Link to post
Share on other sites
Okay, I am having one problem now.

The first row of the database does not show up on the boards. But when I bump a post, the post that should be at the top goes away because it is now supposed to be the first thing to show up.

I am not sure how to fix this with out posting the entire script to my forums. So I guess that is what I am going to do.

Here is the code to post.php:

[code]
<?
include 'header.php';

//*Check to see if the form was submited then add the form to the database*//

if ($_POST['post']){


$subject = trim(addslashes($_POST['subject']));
$body = trim(addslashes($_POST['body']));
$category = trim(strip_tags($_POST['category']));

//*Check if they filled everything out*//

if (($subject == "") || ($body == "")){
echo "You must fill out all fields!";

} else {

echo "<table width='80%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>Successfully Posted!</b></td></table>";

mysql_query("INSERT INTO forum (subject, body, category, posterID, time)
VALUES ('$subject','$body', '$_GET[board]', '$sid', NOW() )")
        or die(mysql_error());

  }
}


//*Print post form*//

print<<<HERE

<p>
<h2>Post A Topic</h2>

<a href="http://northlakestables.com/dog/boards.php?board=$_GET[board]">Go back to board</a><p>

<form action="post.php?board=$_GET[board]&action=post" method="POST">

<table bgcolor='788D7A'>

<td>Subject: <input type=text name="subject" maxlength=50></td>
<tr>
<td><br>Category: $_GET[board]

</td>
</tr>
<td><br>Post:<br>
<textarea rows=10 cols=50 name="body"></textarea><p></td>
</tr>
<td align="center"><input type="submit" name="post" value="Submit"></td>

</table></form>


HERE;


?>
[/code]

This allows the user to create a topic, which the is displayed on boards.php:

[code]
<?
include 'header.php';

//*Check if they submited a reply then add it to the database if submited correctly*//

if ($_POST['reply']){

$topic1 = $_GET['topicID'];

$reply_body = trim(addslashes($_POST['reply_body']));

if ($reply_body == ""){
echo "You must fill out all fields!";

} else {

mysql_query("UPDATE `forum` SET `posts` = posts+1, time=NOW() WHERE `topicID` ='$_GET[topicID]' LIMIT 1 ;")or die("Cannot update! " . mysql_error());

echo "<table width='80%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>Successfully replied!</b></td></table><p>";

mysql_query("INSERT INTO replies (topicID, posterID, body, time)
VALUES ('$topic1','$sid', '$reply_body', NOW() )")
        or die(mysql_error());

  }

}



//*If they want to read the post*//

$topic = $_GET['topicID'];

if ($topic){


$sql2 = "SELECT posterID, topicID, subject, body FROM forum WHERE topicID='$topic'";
$result2 = mysql_query($sql2);
$forum1 = mysql_fetch_array($result2);

$sql4 = "SELECT topicID, posterID, body FROM replies WHERE topicID='$topic'";
$result4 = mysql_query($sql4);


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum1[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);


print<<<HERE

<a href="http://northlakestables.com/dog/boards.php?board=$_GET[board]">Go back to board</a><p>

<table width="90%" bgcolor="49614A">
<tr bgcolor="607062">

<td><b>Subject:</b> $forum1[subject]</td>

<tr bgcolor="607062">

<td align="center"><br>
<p align="left"><b>Posted By:</b> <a href="viewprofile.php?profileid=$player[playerID]">$player[username]</a></p>

$forum1[body]</td>


HERE;

while ($reply4 = mysql_fetch_array($result4)){

$sql6 = "SELECT playerID, username FROM players WHERE playerID='$reply4[posterID]'";
$result6 = mysql_query($sql6);
$player1 = mysql_fetch_array($result6);


echo '<tr bgcolor="788D7A">';
echo "<td align='center'><p align='left'><b>Posted By: </b><a href='viewprofile.php?profileid=$player1[playerID]'>$player1[username]</a></p>";
echo "$reply4[body]</td><tr>";


}

print<<<HERE

<tr bgcolor="788D7A">
<td align="center">
<form action="boards.php?action=reply&board=$_GET[board]&topicID=$topic" method="POST">
<h3>Add a reply</h3>
<textarea rows=10 cols=50 name="reply_body"></textarea><p>
<input name="reply" type="submit" value="Reply">
</form>
</td>

</table>

HERE;

exit;
}



$general = $_GET['board'];

if ($general == general){

echo "<h2>General Board</h2>";

printboards();

exit;
} else if ($general == advertise){

echo "<h2>Advertising Board</h2>";

printboards();

exit;
} else if ($general == buying){

echo "<h2>Buying/Selling Board</h2>";

printboards();

exit;

} else if ($general == art){

echo "<h2>Art Board</h2>";

printboards();

exit;

} else if ($general == help){

echo "<h2>Help Board</h2>";

printboards();

exit;

} else if ($general == contests){

echo "<h2>Contests Board</h2>";

printboards();

exit;

} else if ($general == suggestions){

echo "<h2>Suggestions Board</h2>";

printboards();

exit;

}

//*Chat list*//

print<<<HERE

<h1>The Boards</h1>

<table bgcolor="49614A" cellspacing=7>
<tr bgcolor="788D7A" align="center">

<td><a href="boards.php?board=general"><b>General</b></a><br>
Talk about anything here XD
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=advertise"><b>Advertise</b></a><br>
Here is where you can advertise your dogs, shops, etc.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=buying"><b>buying/selling</b></a><br>
Sell and buy things here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=art"><b>Art</b></a><br>
Show off your art here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=help"><b>help</b></a><br>
Need help? Get your answers here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=contests"><b>Contests</b></a><br>
Hold a contest here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=suggestions"><b>Suggestions</b></a><br>
Have a good suggestion for the site? Share it here.
</td>


HERE;



//*Define function*//

function printboards(){

//*Queries*//

$sql = "SELECT * FROM forum WHERE category='$_GET[board]' ORDER BY time DESC";
$result = mysql_query($sql);
$forum = mysql_fetch_array($result);


//*Print out forum*//

print<<<HERE

<a href="post.php?board=$_GET[board]">New Topic</a><p><br>

<table width="90%" bgcolor='49614A'>

<tr bgcolor='49614A' align="center">

<th><b>Subject</b></th>
<th><b>Posts</b></th>
<th><b>Starter</b></th>
<th><b>Time</b></th>

<tr bgcolor='788D7A' align="center">

HERE;

while ($forum = mysql_fetch_array($result)){


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);

echo "<td><a href='boards.php?board=$_GET[board]&topicID=$forum[topicID]'>$forum[subject]</a></td>";
echo "<td>$forum[posts]</td>";
echo "<td><a href='viewprofile.php?profileid=$player[playerID]'>$player[username]</a></td>";
        echo "<td>$forum[time]</td>";
echo "<tr bgcolor='788D7A' align='center'>";

}

print<<<HERE

</table>

HERE;

}




?>
[/code]
This is where all the posts are listed, and it also allows the user to choose which board they would like to enter.

If you would like to see the output to the scripts <a href="http://northlakestables.com/dog/">CLICK HERE</a>. If you would not like to join, just login with 'guest' as the login and password.

Then just click on the link called 'Boards'...and it will take you to boards.php



EDIT: Oops, I forgot my database info.

<u>TABLE 'forum'</u>
topicID
posterID
subject
body
category
posts
time

<u>TABLE 'replies'</u>
replyID
topicID
posterID
body
time

Share this post


Link to post
Share on other sites
Without looking through all that code have a check to make sure you're not doing something like this:
[code]$query=mysql_query("SELECT * FROM replies ORDER BY `lastreply` LIMIT ".$offset.",".$pagelen." DESC");
$reply=mysql_fetch_array($query);
while ($reply=mysql_fetch_array($query)) {
  show the reply here
}[/code]
A friend did that in their code and it took someone else to point out that the second line was pulling out the first entry and doing nothing with it. I told them to delete the line and everything worked fine.

Are you pulling out the first record by accident then jumping into a loop?

Share this post


Link to post
Share on other sites
This kinda looks like what you just posted...
[code]
while ($forum = mysql_fetch_array($result)){


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);

echo "<td><a href='boards.php?board=$_GET[board]&topicID=$forum[topicID]'>$forum[subject]</a></td>";
echo "<td>$forum[posts]</td>";
echo "<td><a href='viewprofile.php?profileid=$player[playerID]'>$player[username]</a></td>";
        echo "<td>$forum[time]</td>";
echo "<tr bgcolor='788D7A' align='center'>";

}
[/code]

What could I do to fix that though? I need the while loop..

And no, I don't think I am pulling the first record by accident anywhere 0_o

Share this post


Link to post
Share on other sites
I *think* this is what you want:
[code]$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum[posterID]'";
$result1 = mysql_query($sql1);
while ($forum = mysql_fetch_array($result)){
  echo "<td><a href='boards.php?board=$_GET[board]&topicID=$forum[topicID]'>$forum[subject]</a></td>";
  echo "<td>$forum[posts]</td>";
  echo "<td><a href='viewprofile.php?profileid=$player[playerID]'>$player[username]</a></td>";
  echo "<td>$forum[time]</td>";
  echo "<tr bgcolor='788D7A' align='center'>";
}[/code]

Share this post


Link to post
Share on other sites
There isn't a "system" that manages the "bumps".  The way that it works is by storing all of the threads and responses in a table, when the page it loaded, it grabs the last however-many-threads-are-on-a-page ordered by time.

Share this post


Link to post
Share on other sites
Hitman - Yes, that question has already been answered and I already have it up and working. Now we are trying to fix some other errors that I have.

Share this post


Link to post
Share on other sites
[quote author=pocobueno1388 link=topic=104827.msg418690#msg418690 date=1156029110]
Okay, I am having one problem now.

The first row of the database does not show up on the boards. But when I bump a post, the post that should be at the top goes away because it is now supposed to be the first thing to show up.

I am not sure how to fix this with out posting the entire script to my forums. So I guess that is what I am going to do.

Here is the code to post.php:

[code]
<?
include 'header.php';

//*Check to see if the form was submited then add the form to the database*//

if ($_POST['post']){


$subject = trim(addslashes($_POST['subject']));
$body = trim(addslashes($_POST['body']));
$category = trim(strip_tags($_POST['category']));

//*Check if they filled everything out*//

if (($subject == "") || ($body == "")){
echo "You must fill out all fields!";

} else {

echo "<table width='80%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>Successfully Posted!</b></td></table>";

mysql_query("INSERT INTO forum (subject, body, category, posterID, time)
VALUES ('$subject','$body', '$_GET[board]', '$sid', NOW() )")
        or die(mysql_error());

  }
}


//*Print post form*//

print<<<HERE

<p>
<h2>Post A Topic</h2>

<a href="http://northlakestables.com/dog/boards.php?board=$_GET[board]">Go back to board</a><p>

<form action="post.php?board=$_GET[board]&action=post" method="POST">

<table bgcolor='788D7A'>

<td>Subject: <input type=text name="subject" maxlength=50></td>
<tr>
<td><br>Category: $_GET[board]

</td>
</tr>
<td><br>Post:<br>
<textarea rows=10 cols=50 name="body"></textarea><p></td>
</tr>
<td align="center"><input type="submit" name="post" value="Submit"></td>

</table></form>


HERE;


?>
[/code]

This allows the user to create a topic, which the is displayed on boards.php:

[code]
<?
include 'header.php';

//*Check if they submited a reply then add it to the database if submited correctly*//

if ($_POST['reply']){

$topic1 = $_GET['topicID'];

$reply_body = trim(addslashes($_POST['reply_body']));

if ($reply_body == ""){
echo "You must fill out all fields!";

} else {

mysql_query("UPDATE `forum` SET `posts` = posts+1, time=NOW() WHERE `topicID` ='$_GET[topicID]' LIMIT 1 ;")or die("Cannot update! " . mysql_error());

echo "<table width='80%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>Successfully replied!</b></td></table><p>";

mysql_query("INSERT INTO replies (topicID, posterID, body, time)
VALUES ('$topic1','$sid', '$reply_body', NOW() )")
        or die(mysql_error());

  }

}



//*If they want to read the post*//

$topic = $_GET['topicID'];

if ($topic){


$sql2 = "SELECT posterID, topicID, subject, body FROM forum WHERE topicID='$topic'";
$result2 = mysql_query($sql2);
$forum1 = mysql_fetch_array($result2);

$sql4 = "SELECT topicID, posterID, body FROM replies WHERE topicID='$topic'";
$result4 = mysql_query($sql4);


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum1[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);


print<<<HERE

<a href="http://northlakestables.com/dog/boards.php?board=$_GET[board]">Go back to board</a><p>

<table width="90%" bgcolor="49614A">
<tr bgcolor="607062">

<td><b>Subject:</b> $forum1[subject]</td>

<tr bgcolor="607062">

<td align="center"><br>
<p align="left"><b>Posted By:</b> <a href="viewprofile.php?profileid=$player[playerID]">$player[username]</a></p>

$forum1[body]</td>


HERE;

while ($reply4 = mysql_fetch_array($result4)){

$sql6 = "SELECT playerID, username FROM players WHERE playerID='$reply4[posterID]'";
$result6 = mysql_query($sql6);
$player1 = mysql_fetch_array($result6);


echo '<tr bgcolor="788D7A">';
echo "<td align='center'><p align='left'><b>Posted By: </b><a href='viewprofile.php?profileid=$player1[playerID]'>$player1[username]</a></p>";
echo "$reply4[body]</td><tr>";


}

print<<<HERE

<tr bgcolor="788D7A">
<td align="center">
<form action="boards.php?action=reply&board=$_GET[board]&topicID=$topic" method="POST">
<h3>Add a reply</h3>
<textarea rows=10 cols=50 name="reply_body"></textarea><p>
<input name="reply" type="submit" value="Reply">
</form>
</td>

</table>

HERE;

exit;
}



$general = $_GET['board'];

if ($general == general){

echo "<h2>General Board</h2>";

printboards();

exit;
} else if ($general == advertise){

echo "<h2>Advertising Board</h2>";

printboards();

exit;
} else if ($general == buying){

echo "<h2>Buying/Selling Board</h2>";

printboards();

exit;

} else if ($general == art){

echo "<h2>Art Board</h2>";

printboards();

exit;

} else if ($general == help){

echo "<h2>Help Board</h2>";

printboards();

exit;

} else if ($general == contests){

echo "<h2>Contests Board</h2>";

printboards();

exit;

} else if ($general == suggestions){

echo "<h2>Suggestions Board</h2>";

printboards();

exit;

}

//*Chat list*//

print<<<HERE

<h1>The Boards</h1>

<table bgcolor="49614A" cellspacing=7>
<tr bgcolor="788D7A" align="center">

<td><a href="boards.php?board=general"><b>General</b></a><br>
Talk about anything here XD
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=advertise"><b>Advertise</b></a><br>
Here is where you can advertise your dogs, shops, etc.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=buying"><b>buying/selling</b></a><br>
Sell and buy things here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=art"><b>Art</b></a><br>
Show off your art here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=help"><b>help</b></a><br>
Need help? Get your answers here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=contests"><b>Contests</b></a><br>
Hold a contest here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=suggestions"><b>Suggestions</b></a><br>
Have a good suggestion for the site? Share it here.
</td>


HERE;



//*Define function*//

function printboards(){

//*Queries*//

$sql = "SELECT * FROM forum WHERE category='$_GET[board]' ORDER BY time DESC";
$result = mysql_query($sql);
$forum = mysql_fetch_array($result);


//*Print out forum*//

print<<<HERE

<a href="post.php?board=$_GET[board]">New Topic</a><p><br>

<table width="90%" bgcolor='49614A'>

<tr bgcolor='49614A' align="center">

<th><b>Subject</b></th>
<th><b>Posts</b></th>
<th><b>Starter</b></th>
<th><b>Time</b></th>

<tr bgcolor='788D7A' align="center">

HERE;

while ($forum = mysql_fetch_array($result)){


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);

echo "<td><a href='boards.php?board=$_GET[board]&topicID=$forum[topicID]'>$forum[subject]</a></td>";
echo "<td>$forum[posts]</td>";
echo "<td><a href='viewprofile.php?profileid=$player[playerID]'>$player[username]</a></td>";
        echo "<td>$forum[time]</td>";
echo "<tr bgcolor='788D7A' align='center'>";

}

print<<<HERE

</table>

HERE;

}




?>
[/code]
This is where all the posts are listed, and it also allows the user to choose which board they would like to enter.

If you would like to see the output to the scripts <a href="http://northlakestables.com/dog/">CLICK HERE</a>. If you would not like to join, just login with 'guest' as the login and password.

Then just click on the link called 'Boards'...and it will take you to boards.php



EDIT: Oops, I forgot my database info.

<u>TABLE 'forum'</u>
topicID
posterID
subject
body
category
posts
time

<u>TABLE 'replies'</u>
replyID
topicID
posterID
body
time
[/quote]


This is my problem now.

Share this post


Link to post
Share on other sites
Instead of a query to find the replies then a separate query for each reply to get the username why don't you have a single joined query and one simple loop?

Share this post


Link to post
Share on other sites
the password and login did not work.

how did you enter the time please was it a timestamp.

example

time();

Share this post


Link to post
Share on other sites
I entered the time with:

NOW()

Barand - I don't understand how I would do that. Would you mind showing me?

Share this post


Link to post
Share on other sites
[code]<?php
$sql4 = "SELECT r.topicID, r.posterID, r.body, p.username
          FROM replies r INNER JOIN players p
          ON r.posterID = p.playerID
          WHERE r.topicID='$topic'";
$result4 = mysql_query($sql4);
?>[/code]



Share this post


Link to post
Share on other sites
Thanks Barand XD The problem is still there though...Here is the new code.

[code]
<?
include 'header.php';

//*Check if they submited a reply then add it to the database if submited correctly*//

if ($_POST['reply']){

$topic1 = $_GET['topicID'];

$reply_body = trim(addslashes($_POST['reply_body']));

if ($reply_body == ""){
echo "You must fill out all fields!";

} else {

mysql_query("UPDATE `forum` SET `posts` = posts+1, time=NOW() WHERE `topicID` ='$_GET[topicID]' LIMIT 1 ;")or die("Cannot update! " . mysql_error());

echo "<table width='80%' bgcolor='49614A'><td align='center' bgcolor='788D7A'><b>Successfully replied!</b></td></table><p>";

mysql_query("INSERT INTO replies (topicID, posterID, body, time)
VALUES ('$topic1','$sid', '$reply_body', NOW() )")
        or die(mysql_error());

  }

}



//*If they want to read the post*//

$topic = $_GET['topicID'];

if ($topic){


$sql2 = "SELECT posterID, topicID, subject, body FROM forum WHERE topicID='$topic'";
$result2 = mysql_query($sql2);
$forum1 = mysql_fetch_array($result2);

$sql4 = "SELECT r.topicID, r.posterID, r.body, p.username
          FROM replies r INNER JOIN players p
          ON r.posterID = p.playerID
          WHERE r.topicID='$topic'";
$result4 = mysql_query($sql4);

$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum1[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);


print<<<HERE

<a href="http://northlakestables.com/dog/boards.php?board=$_GET[board]">Go back to board</a><p>

<table width="90%" bgcolor="49614A">
<tr bgcolor="607062">

<td><b>Subject:</b> $forum1[subject]</td>

<tr bgcolor="607062">

<td align="center"><br>
<p align="left"><b>Posted By:</b> <a href="viewprofile.php?profileid=$player[playerID]">$player[username]</a></p>

$forum1[body]</td>


HERE;

while ($reply4 = mysql_fetch_array($result4)){

$sql6 = "SELECT playerID, username FROM players WHERE playerID='$reply4[posterID]'";
$result6 = mysql_query($sql6);
$player1 = mysql_fetch_array($result6);


echo '<tr bgcolor="788D7A">';
echo "<td align='center'><p align='left'><b>Posted By: </b><a href='viewprofile.php?profileid=$player1[playerID]'>$player1[username]</a></p>";
echo "$reply4[body]</td><tr>";


}

print<<<HERE

<tr bgcolor="788D7A">
<td align="center">
<form action="boards.php?action=reply&board=$_GET[board]&topicID=$topic" method="POST">
<h3>Add a reply</h3>
<textarea rows=10 cols=50 name="reply_body"></textarea><p>
<input name="reply" type="submit" value="Reply">
</form>
</td>

</table>

HERE;

exit;
}



$general = $_GET['board'];

if ($general == general){

echo "<h2>General Board</h2>";

printboards();

exit;
} else if ($general == advertise){

echo "<h2>Advertising Board</h2>";

printboards();

exit;
} else if ($general == buying){

echo "<h2>Buying/Selling Board</h2>";

printboards();

exit;

} else if ($general == art){

echo "<h2>Art Board</h2>";

printboards();

exit;

} else if ($general == help){

echo "<h2>Help Board</h2>";

printboards();

exit;

} else if ($general == contests){

echo "<h2>Contests Board</h2>";

printboards();

exit;

} else if ($general == suggestions){

echo "<h2>Suggestions Board</h2>";

printboards();

exit;

}

//*Chat list*//

print<<<HERE

<h1>Boards do not work perfectly yet!</h1><br>

<h1>The Boards</h1>

<table bgcolor="49614A" cellspacing=7>
<tr bgcolor="788D7A" align="center">

<td><a href="boards.php?board=general"><b>General</b></a><br>
Talk about anything here XD
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=advertise"><b>Advertise</b></a><br>
Here is where you can advertise your dogs, shops, etc.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=buying"><b>buying/selling</b></a><br>
Sell and buy things here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=art"><b>Art</b></a><br>
Show off your art here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=help"><b>help</b></a><br>
Need help? Get your answers here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=contests"><b>Contests</b></a><br>
Hold a contest here.
</td>
<tr bgcolor="788D7A" align="center">
<td><a href="boards.php?board=suggestions"><b>Suggestions</b></a><br>
Have a good suggestion for the site? Share it here.
</td>


HERE;



//*Define function*//

function printboards(){

//*Queries*//

$sql = "SELECT * FROM forum WHERE category='$_GET[board]' ORDER BY time DESC";
$result = mysql_query($sql);
$forum = mysql_fetch_array($result);


//*Print out forum*//

print<<<HERE

<a href="post.php?board=$_GET[board]">New Topic</a><p><br>

<table width="90%" bgcolor='49614A'>

<tr bgcolor='49614A' align="center">

<th><b>Subject</b></th>
<th><b>Posts</b></th>
<th><b>Starter</b></th>
<th><b>Time</b></th>

<tr bgcolor='788D7A' align="center">

HERE;

while ($forum = mysql_fetch_array($result)){


$sql1 = "SELECT playerID, username FROM players WHERE playerID='$forum[posterID]'";
$result1 = mysql_query($sql1);
$player = mysql_fetch_array($result1);

echo "<td><a href='boards.php?board=$_GET[board]&topicID=$forum[topicID]'>$forum[subject]</a></td>";
echo "<td>$forum[posts]</td>";
echo "<td><a href='viewprofile.php?profileid=$player[playerID]'>$player[username]</a></td>";
        echo "<td>$forum[time]</td>";
echo "<tr bgcolor='788D7A' align='center'>";

}

print<<<HERE

</table>

HERE;

}

?>
[/code]

Share this post


Link to post
Share on other sites
<? $ord=date("U")-0; ?>
and make a new row called ord in your mysql table enter the variable $ord each time a new thread is posted  or when a reply is added update that row and used order by ord desc
thats what i use on my forums and works perfect :) hope this helps

Share this post


Link to post
Share on other sites
I think I am going to make a new post tomorrow, because I am confusing people. I already had the first question answered, then I asked another one somewhere on the first page...I don't think everyone is reading it.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.