Page 1 of 1

Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 3:15 pm
by RRGP
Hi everyone...

I have been working on a forum project, where i have everything working well except for one thing: Organizating the forum by topics.

I searched around but I can't find anything regarding to my problem, and I still don't have many expirience with php. So, what I'm asking is: does someone knows how to make topics in a forum(without resorting to phpBB)??

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 3:34 pm
by jayshields
Are you talking about a database schema? If so, check out an existing forums' database schema and take ideas from that.

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 3:54 pm
by RRGP
something like that, but i don't know who to express that into theweb page... basicly I just want to know what to do just for going into a postboard by cliking in a topic link, kinda like how this site works: you clik in a topic and go to where you can post your messages. I'm just missing the way to connect a topic to a messageboard...

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 4:44 pm
by mischievous
Can you try an explain what you mean exactly by topic vrs message board? because there are a variety of meaning behind that... There are categorys, sub categories, then topics, then posts ? :roll:

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 5:31 pm
by RRGP
sorry...

What I mean to do is something like the topics structure of this web site. Everything works except the structure of the topics. The problem is that i can´t make the conection between topic and the page were you post your messagens.


To post the messanges i have made a While cicle that goes to the database, picks the data and posts it until there is none left. I wanted to apply the same basis with the topcis: pick them up from the database (id_topic, name, details...) and post them allowing to, when someone clicks in one of them, it leads you to the area where you post.

What happens is that i don't know how to assuciate each topic with each message, since there are more than 1 topic and the messages aren´t only in one of them. I tryed to make a variable for each page to identify which topics is it, but it those work... I don't think I can explain this better then it is explained...

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 5:41 pm
by mischievous
Ok... well if you look at the url for this forum it states /viewtopic.php?f=1&t=101464

So, Forum_ID = 1 and Topic_ID = 101464.

Thus->

Code: Select all

"SELECT * FROM messages WHERE Topic_ID = $T";
??????

However, it depends on your database schema...

Not sure if that answers what your asking though...

Re: Please, can someone help me with my forum ?(topics question)

Posted: Tue Jun 09, 2009 6:08 pm
by RRGP
yes it does, it resebles to what i had already done. but how do i identify the php page as being the page nº 1323542 whitout having to go edit te page code and put $id_topic=1323542?... I want it to do automaticaly...

Re: Please, can someone help me with my forum ?(topics question)

Posted: Wed Jun 10, 2009 12:33 pm
by mischievous
right... you just run a get call

$forumID = $_GET['F'];
$topicID = $_GET['T'];

that will pick up dynamically what the topic is then you just pass it to the query to create the page dynamically.

EX:

view.php?f=1&t=101464 // $topicID would equal 1014464

view.php?f=1&t=123443 // $topicID would equal 123443

view.php?f=1&t=155764 // $topicID would equal 155764

Re: Please, can someone help me with my forum ?(topics question)

Posted: Thu Jun 11, 2009 4:40 pm
by RRGP
And where do I put that? oon the page that you can see the topics links and make an include or in another one? I also don't get the query part... can you expain it a little more?

Re: Please, can someone help me with my forum ?(topics question)

Posted: Thu Jun 11, 2009 5:55 pm
by mikemike
I think you need to do some basic PHP and MySQL tutorials so you understand the basic concepts a little better.
Googled

We can't really help you until you know the basic concepts like how $_GET works and basic MySQL queries.

Re: Please, can someone help me with my forum ?(topics question)

Posted: Thu Jun 11, 2009 6:43 pm
by RRGP
... man, I KNOW how to deal with the basics of php, the thing that I don't know how to do is the topics organization, how to call topics...

...Google? I have searched everywere but i didn't find a clear way of how to do it,(gone from tuturials to seing the codes of the others....)

Re: Please, can someone help me with my forum ?(topics question)

Posted: Thu Jun 11, 2009 9:14 pm
by mischievous
put it on all the pages above where you generate the mysql query!


Query:
mysql_query("SELECT * FROM topics WHERE topic_id = $topicID");

Re: Please, can someone help me with my forum ?(topics question)

Posted: Fri Jun 12, 2009 5:09 am
by RRGP
Thanks!

Re: Please, can someone help me with my forum ?(topics question)

Posted: Mon Jun 15, 2009 7:06 pm
by RRGP
I am getting this error in my topicview.php that i can't fix:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/contas/19650/public_html/desportuga/view_topic.php on line 18

Can someone help me figure out how to solve it?


(Here is the code)

<?php
session_start();

include('BD.inc.php');



$sql = "SELECT * FROM mensagens WHERE id_topico='".$id_topico."'";
$resultado = mysql_query($sql,$link);
//$valores=mysql_fetch_array($result);

$sqli = "SELECT * FROM responde, mensagens WHERE mensagens.id_mens = responde.id_mens";
$resultadoi = mysql_query($sqli,$link);
$valoresi=mysql_fetch_array($resultadoi);



While ($valores=mysql_fetch_array($resultado))
{

//Mensagem basica::

echo "<br><br><br>".$valores["nome_mens"];
echo "<br>".$valores["conteudo"];

if ($valores["n_util"]==$_SESSION["n_util"])
{
?> "<br><a href=<?php $PHP_SELF ?>al=1>Editar</a> &nbsp; <a href=<?php $PHP_SELF ?>?a=2>Apagar</a><?php
switch ($_GET["a"])
{
case 1:@include('editar_mens.html');break;
case 2:@include('apagar_mens.html');break;
}
}

//Comentário à mensagem :

While ($valoresi=mysql_fetch_array($resultadoi))
{
echo "<br><br><br><hr>".$valores["nome_mens"];
echo "<br><hr>".$valoresi["coment_mens"];

if ($valores["n_util"]==$_SESSION["n_util"])
{
?><br><a href=<?php $PHP_SELF ?>?b=1>Editar</a> &nbsp; <a href=<?php $PHP_SELF ?>?b=2>Editar</a><?php
switch ($_GET["b"])
{
case 1:@include('editar_coment.html');break;
case 2:@include('apagar_coment.html');break;
}
}
}

?>
<br><br> <a href=<?php $PHP_SELF ?>?c=1>Postar Nova Mensagem</a><?php
switch ($_GET["c"])
{
case 1:@include('enviar_mensagem.php');break;
}
?>
</body>
<?php
}
?>