php array into mysql

Posted by mckenzie on Stack Overflow See other posts from Stack Overflow or by mckenzie
Published on 2010-04-10T07:09:10Z Indexed on 2010/04/10 7:13 UTC
Read the original article Hit count: 174

Filed under:
|

Hello,

$sql_where = '';
$exclude = '30,35,36,122,123,124,125'; 

if($exclude != '') 
{     
    $exclude_forums = explode(',', $exclude); 
    foreach ($exclude_forums as $id) 
    { 
        if ($id > 0) 
        { 
            $sql_where = ' AND forum_id <> ' . trim($id); 
        } 
    }
} 

$sql = 'SELECT topic_title, forum_id, topic_id, topic_type, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time
   FROM ' . TOPICS_TABLE . '
   WHERE topic_status <> 2
      AND topic_approved = 1
      ' . $sql_where . '
   ORDER BY topic_time DESC';

The above code i use to exclude the id of forum to be displayed on sql queries.

Why doesn't it work and still display it?

Any solution

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql