phpretard Posted July 29, 2009 Share Posted July 29, 2009 Why doesn't tis work??? connect(); $page_title = mysql_query("select * from category where id='".intval($_GET['c'])."' "); while($title = mysql_fetch_assoc($page_title)) { if ($title['sub_cat'] == 0){ echo"<div style=\"color:#A00201; font-style:italic; padding-top:5px;; font-size:22px; font-weight:bold;\">".$title['long_name']."<hr /></div>"; }else{ $sub_title = mysql_query("select * from category_sub where cat_id='".$title['id']."' ") or die(mysql_error()); while($stitle = mysql_fetch_assoc($sub_title)); { echo"<div style=\"color:#A00201; font-style:italic; padding-top:5px;; font-size:22px; font-weight:bold;\">".$stitle['sub_name']."TEST<hr /></div>"; } mysql_free_result($sub_title); } } mysql_free_result($page_title); Its driving me mad!!! Quote Link to comment Share on other sites More sharing options...
gevans Posted July 29, 2009 Share Posted July 29, 2009 What's it meant to do? What is it doing? Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 29, 2009 Share Posted July 29, 2009 Not sure but maybe it is that you are using the same variable in both while loops ($title)? Like gevans mentioned we need more information... how does it not work, what should happen and what happens.. crystal ball is under maintenance atm. Quote Link to comment Share on other sites More sharing options...
phpretard Posted July 29, 2009 Author Share Posted July 29, 2009 One loop is $title the other is $stitle I have narrowed it down and this doesn't even work... - I am checking a row in the DB for zero or one. - if it's 0 it should display a div. - else it should display the other div. I am sure the tables are setup right because if I change: $title['sub_cat'] == 0 - TO - $title['sub_cat'] == 1 It displays the TEST but not the other... $page_title = mysql_query("select * from category where id='".intval($_GET['c'])."' "); while($title = mysql_fetch_assoc($page_title)) { if ($title['sub_cat'] == 0){ // ZERO CHECK echo"<div>".$title['long_name']."</div>"; }else{echo"<div>TEST</div>";} } mysql_free_result($page_title); Quote Link to comment Share on other sites More sharing options...
TeNDoLLA Posted July 29, 2009 Share Posted July 29, 2009 What you could do is echo out the query (or queries) and try it/them from some SQL prog or SQL command line and see if the results are what you expect them to are. It smells like $title['sub_cat'] is not containing the information you think it is. Also you can var_dump variables to see what they hold inside. Quote Link to comment Share on other sites More sharing options...
phpretard Posted July 29, 2009 Author Share Posted July 29, 2009 I tried echo $title['sub_cat']; It echos the 0 but not the 1 ???? 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.