Results 1 to 3 of 3

Thread: SQL question (PHPNuke block)

  1. #1
    Join Date
    May 2003
    Posts
    2

    SQL question (PHPNuke block)

    Hello - PHP-type newbie here: I have a question regarding an SQL statement in PHP (PostNuke forums module)

    This function basically prints the titles of the most recent forum posts in a little block on the homepage.

    Is there a way I can get the SQL to filter out certain forums from having thier headlines posted in this block? I was thinking this might work below - (my changes are adding the "AND NOT forum_id='8'") Does anyone know if this is the correct syntax?

    It does not seem to work....

    ================================================== =============
    $sql = "SELECT forum_id, topic_id, topic_title FROM ".$prefix."_bbtopics ORDER BY topic_time DESC LIMIT 10";

    $result = $db->sql_query($sql);

    while ($row = $db->sql_fetchrow($result)) {

    $forum_id = $row[forum_id];

    $topic_id = $row[topic_id];

    $topic_title = $row[topic_title];

    $sql2 = "SELECT auth_view, auth_read FROM ".$prefix."_bbforums WHERE forum_id='$forum_id'AND NOT forum_id='8'

    $result2 = $db->sql_query($sql2);

    $row2 = $db->sql_fetchrow($result);

    $auth_view = $row2[auth_view];

    $auth_read = $row2[auth_read];

    if (($auth_view != 2) OR ($auth_read != 2)) {

    $content .= "<img src=\"images/arrow.gif\" border=\"0\" alt=\"\" title=\"\" width=\"9\" height=\"9\">&<a href=\"modules.php?name=Forums&file=viewtopic&t=$t opic_id\">$topic_title</a><br>";

    }

    }

    ================================================== =============

    See the output at www.oldwarriors.org (right side, look for "Forums Ramblings"

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    Instead of AND NOT forum_id='8' , try AND forum <> '8'

    Since you already use PHP and MySQL, there is no reason why you can't also install phpMyAdmin. It has a tool that can convert your SQL statement to PHP.

    TIP : Always test you SQL scripts in a SQL Query app ( like phpMyAdmin ) to see if the SQL statement returns the desired results. Than you can work the SQL into your app.

    Cheers

  3. #3
    Join Date
    May 2003
    Posts
    2
    Thanks for the help!

    At first it did not work, but soon I discovered it was because I was putting it in the 2nd WHERE statement - I added it to the 1st WHERE statement and it works just dandy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •