I will post any code about my topics if you want to see it
how to lock a topic in a forum?
Moderator: General Moderators
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
how to lock a topic in a forum?
I'm making a forum and I noticed that lots of forums have topics that are locked and stay at the top of the list of topics. So I was wondering how to you do this?
I will post any code about my topics if you want to see it
I will post any code about my topics if you want to see it
Re: how to lock a topic in a forum?
Their being locked and their being stickied at the top of forums are two entirely separate issues. Both can be accomplished by setting flags on the threads in question.
Code: Select all
UPDATE table_name SET sticky = 1 WHERE thread_id = foo-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
ok but since I am using mysql with the forum will I need to add sticky to the topics table?
and what do you mean here
and how will I lock the topic?
and what do you mean here
Code: Select all
WHERE thread_id = foo?Re: how to lock a topic in a forum?
I can't really give you anything specific as I have no idea how your tables are setup. Every post must have a thread ID, no?
Locking it would simply be setting another flag.
Locking it would simply be setting another flag.
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
but what do you mean by setting a flag?
Re: how to lock a topic in a forum?
In the database. Have a column in your threads table for whether or not the thread is stickied, and another for whether or not it is locked.
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
no I have topicID, topicSubject, topicDate, topicCategory,and topicByUser. So I will need to add two more columns for sticky and locked?
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
ok thanks I understand but what will the code be when sticky and locked are flagged?
Re: how to lock a topic in a forum?
Just toggle that column from 0 to 1
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
but what code to go with that like if(sticky = 1 & locked = 1)?
Re: how to lock a topic in a forum?
I don't really understand what you're asking. What code to go where? To do what?
-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
I am making the forum in php so I need to write some php code to make sticky and locked work
heres my code for creating a category:
so I will some php code to make sticky and lock to work
heres my code for creating a category:
Code: Select all
<?php
//create_cat.php
include 'connect.php';
include 'header.php';
echo '<h2>Create a category</h2>';
if($_SESSION['signed_in'] == false | $_SESSION['userLevel'] != 1 )
{
echo 'Sorry, you do not have sufficient rights to access this page.';
}
else
{
if($_SERVER['REQUEST_METHOD'] != 'POST')
{
//the form hasn't been posted yet, display it
echo '<form method="post" action="">
Category name: <input type="text" name="categoryName" /><br />
Category description:<br /> <textarea name="categoryDescription" /></textarea><br /><br />
<input type="submit" value="Add category" />
</form>';
}
else
{
$sql = "INSERT INTO categories(categoryName, categoryDescription)
VALUES('" . mysql_real_escape_string($_POST['categoryName']) . "',
'" . mysql_real_escape_string($_POST['categoryDescription']) . "')";
$result = mysql_query($sql);
if(!$result)
{
echo 'Error' . mysql_error();
}
else
{
echo 'New category succesfully added.';
}
}
}
include 'footer.php';
?>
Last edited by beginner123 on Fri Mar 02, 2012 1:25 pm, edited 1 time in total.
Re: how to lock a topic in a forum?
Code: Select all
UPDATE table_name SET sticky = 1 WHERE topic_id = whatever-
beginner123
- Forum Commoner
- Posts: 70
- Joined: Fri Feb 24, 2012 9:56 am
Re: how to lock a topic in a forum?
I don't understand how the forum will know what sticky means...
how does it know that sticky will make the topic stay at the top of the list if i don't write any code for it
how does it know that sticky will make the topic stay at the top of the list if i don't write any code for it