timmah1 Posted March 30, 2012 Share Posted March 30, 2012 I have a drop down that shows all categories in a database. I have a drop down that shows headerid and appid based off of the catagories. What I need to do is show only the categories that headerid and appid do not match. I've tried this $formex = "SELECT headerid,appid FROM appforms WHERE headerid NOT LIKE '{$row->catid}%' AND appid NOT LIKE '$appid%'"; and this $formex = "SELECT headerid,appid FROM appforms WHERE headerid != {$row->catid} AND appid != $appid"; and it's still showing every category. I need to exclude the rows that headerid and appid are equal too. Can someone let me know what I'm doing wrong? Thanks in advance Quote Link to comment Share on other sites More sharing options...
timmah1 Posted March 30, 2012 Author Share Posted March 30, 2012 Maybe I need more clarification The entire code is like so: include($_SERVER['DOCUMENT_ROOT']."/inc/config.db.php"); $appid = '44'; $sql="SELECT t1.*,t2.category FROM app_categories as t1 INNER JOIN categories as t2 on t1.catid=t2.id WHERE t1.appid=$appid ORDER BY t1.display_order ASC"; $rs = mysql_query($sql); if($rs && mysql_num_rows($rs) > 0){ while ($row = mysql_fetch_object($rs)) { $forms="SELECT headerid,appid FROM appforms WHERE 'headerid' != '{$row->catid}' AND 'appid' != '$appid'"; $exis = mysql_query($forms); $title = empty($row->custom_title) ? stripslashes($row->category) : stripslashes($row->custom_title); echo "<option value='http://www.localfreeapps.com/panel/testing/connectors/sample/projects/contactform.php?id=$appid&headerid={$row->catid}'>$title</option>"; } } So, with this, I need to show in the drop-down every header from the categories table, unless that headerid and appid match in the appforms table. I hope this makes sense. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 31, 2012 Share Posted March 31, 2012 I think you're confusing sematic AND with boolean AND. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.