White_Lily Posted October 17, 2012 Share Posted October 17, 2012 Hi, I have a page that allows you to select pages that you want have related pages on. The problem I'm having is that its not displaying anything, not even the types of pages that I want it to display and have specified. <?php $getCategories = select("pages", "id, name", "page_switch = 1"); while ($categories = mysql_fetch_array($getCategories)) { //if(!isset($usedCats[$categories['id']])){ if($categories["type"] == 2 && $categories["type"] == 4 && $categories["type"] == 5){ echo "<option value='".$categories['id']."'>".$categories['name']."</option>"; } //} } ?> I can't seem to figure out why it's not displaying anything Any help would be appreciated. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 17, 2012 Share Posted October 17, 2012 How can a value equal 2, 4 and 5 all at the same time? Try using "||" instead of "&&" Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 17, 2012 Author Share Posted October 17, 2012 Got a point there lol guess i didn't see it like that - will try the || Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 17, 2012 Author Share Posted October 17, 2012 No it didnt work, and error reporting isnt showing any errors either. php,ini id set to: display_errors = on error_reporting = -1 Quote Link to comment Share on other sites More sharing options...
Barand Posted October 17, 2012 Share Posted October 17, 2012 No it didnt work, ... I think you've read enough posts on this board to know that statement needs more explanation Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 17, 2012 Author Share Posted October 17, 2012 A friend managed to fix it for me. Quote Link to comment Share on other sites More sharing options...
Barand Posted October 17, 2012 Share Posted October 17, 2012 White_Lily, Have you ever searched the internet with a problem only to find many posts all asking similar questions but no-one actually posting a solution. Don't you find it frustrating and annoying? Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 17, 2012 Author Share Posted October 17, 2012 I will post the solution tomorrow when I am back at work. Sorry. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 18, 2012 Author Share Posted October 18, 2012 (edited) <label>Page:</label> <select name="catSel" style="width: 300px;"> <? $getCategories = select("pages", "id, name", "(page_switch = 1) AND (type = 2 OR type = 4 OR type = 5)"); // this line is the fix while ($categories = mysql_fetch_array($getCategories)) { echo "<option value='".$categories['id']."'>".$categories['name']."</option>"; } ?> </select> Edited October 18, 2012 by White_Lily Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 18, 2012 Share Posted October 18, 2012 You should use the full PHP tags instead of the short tags, and you need to/should use htmlspecialchars () to ensure that there are no problems with (accidental) HTML injections. Also, labels without a for attribute, pointing to a identically named id attribute of an input element, is quite useless. Lastly, you could have solved this using MySQL's IN() function. Allows for a much cleaner solution, especially if you have many IDs you want to match. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 18, 2012 Author Share Posted October 18, 2012 (edited) I didnt write the code for any of this, I'm merely adding to it/fixing errors. The way it was written wasn't really my choice unfortunately. You have confused me with the whole labels thing... sorry Edited October 18, 2012 by White_Lily Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 18, 2012 Share Posted October 18, 2012 <label for="inp_name">Name:</label> <input id="inp_name" type="text" name="name"> Click on the label, and the associated input field gains focus. Quote Link to comment Share on other sites More sharing options...
White_Lily Posted October 18, 2012 Author Share Posted October 18, 2012 Ah that! Yeah I know about that sorry. If there are any id's (or classes for that matter) then it's because we are using TinyMCE to display text fields etc. 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.