Jump to content

Category and forums in one table.


mark25

Recommended Posts

Let say I have 2 categories and 2 forums in a table(mysql).

 

Table: forums

- fid            name            type          order

    1        Category1          c              1

    2          Forum1            f                1

    3          Forum2            f                1

    4        Category2          c              2

 

How can I break each category let say.

 

<table>
<tr>
<td bgcolor=\"#000000\">Category1</td>
</tr>
<tr>
<td bgcolor=\"#000000\">Forum1</td>
</tr>
</table>
//------ Category 1 ends here -----
<br>
//------ New Category ------
<table>
<tr>
<td bgcolor=\"#000000\">Category2</td>
</tr>
<tr>
<td bgcolor=\"#000000\">Forum2</td>
</tr>
</table>

 

You have any idea on how can I do this?

Link to comment
https://forums.phpfreaks.com/topic/106310-category-and-forums-in-one-table/
Share on other sites

I am confused.  Do you want to take the data from the database and enter it into the webpage?

 

Yes. Is there any way I can do it? Most of the php forums can do it?

 

$sql= "SELECT * FROM forums";
$result = $db->query($sql);
while($rows = $db->fetch_array($result)){
if($rows['type'] == "c")
{
$forumcat = "category";
}
else
{
$forumcat = "forum_start";
}

eval("\$display = \"".$tp->get("$forumcat")."\";"); // Get template in the database.
echo $display;

}

using your database structure, how can you tell that forumx belongs in categoryx? I don't see anything creating a relationship between a forum and it's category.

 

Oh. lol. I forgot to post it.

 

Table: forums

- fid            name            type          order        parent

    1        Category1          c              1

    2          Forum1            f                1            1

    3          Forum2            f                1            4

    4        Category2          c                2

 

Any idea how can I do this?

hm, i would have categories in their own table and have a key from forums to the id of the category. then it would be simple to

 

SELECT A.name, B.name FROM categories A, forums B WHERE B.cat_id = A.id GROUP BY B.cat_id ORDER BY A.name

 

Still you can't line break (br) each categories. :( .

Archived

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

×
×
  • Create New...

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.