1 (edited by bmpwe 2006-11-08 06:35)

Topic: php code to create new forum?

I need to create a few hundred forums. The forum admin page seems to get a bit cumbersome after about 50.... so, I'd like to do it with php.

I've found this chunk of code in admin_forums.php (around line 37) that I believe will do the trick:

if (isset($_POST['add_forum']))
{
    confirm_referrer('admin_forums.php');

    $add_to_cat = intval($_POST['add_to_cat']);
    if ($add_to_cat < 1)
        message($lang_common['Bad request']);

    $db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());

How can I modify this code to simply insert a forum named $forum_name into a categorie named $categorie_name?

Thanks for any help!

Re: php code to create new forum?

do a select query on the category name to get the category ID, then insert a row into forums with forum_name and cat_id values of $forum_name and the ID you got from the previous query, respectively