Jump to content


Photo

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


  • Please log in to reply
21 replies to this topic

#1 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 19 August 2006 - 03:13 AM

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

#2 Woolf

Woolf
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 19 August 2006 - 04:03 AM

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). :)

#3 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 19 August 2006 - 04:12 AM

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

#4 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 19 August 2006 - 11:11 PM

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:

<?
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;


?>

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

<?
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;

}




?>
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://northlakestab...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

#5 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:19 PM

Without looking through all that code have a check to make sure you're not doing something like this:
$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
}
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?
Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#6 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 19 August 2006 - 11:29 PM

This kinda looks like what you just posted...
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'>";

}

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

#7 Yesideez

Yesideez
  • Members
  • PipPipPip
  • Advanced Member
  • 2,334 posts
  • LocationDevon, UK

Posted 19 August 2006 - 11:38 PM

I *think* this is what you want:
$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'>";
}

Not a pro just an enthusiast :)

if (empty($coffee)) {$coffee=new coffee();}

Please surround any code using the CODE tags - I rarely look at anything without them

#8 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 20 August 2006 - 01:04 AM

Nope =/ That gives me the same result.

#9 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 03:21 AM

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.

#10 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 20 August 2006 - 03:46 AM

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.

#11 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 20 August 2006 - 04:58 PM

bump

#12 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 August 2006 - 05:03 PM

what errors you got then ok not bump!
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#13 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 20 August 2006 - 05:15 PM

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:

<?
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;


?>

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

<?
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;

}




?>
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://northlakestab...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



This is my problem now.

#14 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 20 August 2006 - 05:25 PM

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?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#15 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 August 2006 - 05:27 PM

the password and login did not work.

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

example

time();
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#16 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 20 August 2006 - 05:39 PM

I entered the time with:

NOW()

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

#17 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 20 August 2006 - 05:45 PM

<?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);
?>




If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#18 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 21 August 2006 - 02:37 AM

Thanks Barand XD The problem is still there though...Here is the new 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;

}

?>


#19 pocobueno1388

pocobueno1388
  • Members
  • PipPipPip
  • Advanced Member
  • 3,369 posts
  • LocationPalm Beach, Florida

Posted 21 August 2006 - 04:18 AM

bump

#20 desithugg

desithugg
  • Members
  • PipPipPip
  • Advanced Member
  • 281 posts
  • LocationScarborough

Posted 21 August 2006 - 04:18 AM

<? $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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users