Hello!
Finally I joined daniweb. Great stuff in here guys. Anyways lets get to the problem:
I have a page where a number of topics are displayed ( they are added by admin). And to get this list I`m using this script
// Query the database
$gettopic = mysql_query("SELECT * FROM topics ORDER BY id DESC") or die(mysql_query());
// List the topics
while ($row = mysql_fetch_assoc($gettopic))
{
//get data
$id = $row['id'];
$heading = $row['heading'];
$status = $row['status'];
$date_closing = $row['date_closing'];
if ($status==1)
$status_name='Closed';
else
$status_name='Open';
if($status_name=='Closed')
$participate = '-';
else
$participate = "<a href=\"paricipate.php?id=$id" >Participate</a>";
echo "
<tr>
<td>
<a href=\"content.php?id=$id" >$heading</a>
</td>
<td align='center'>
$status_name
</td>
<td align='center'>
$date_closing
</td>
<td align='center'>
$participate
</td>
</tr>
";
}
Everything works fine here. The page displays all the topics and Status thing works fine as well.
This all is being taken from topics table.
So there is another table called responses where is a list of users participating in selected topics.
| id | user_id | topic_id | content |
So the question is:
How can I make script close the topic ( as it does in the script with data taken from Status cell) in case user is already participating with his content?
But topics where he is not participating - still available for him unless he doesn`t publish his content in those. In other words - if user id is matching the topic id => script closes the topic for that user. How could I make it work?
Tried to experiment with JOINs and other while loops but no successful results.
Any ideas?
Thank you!