hcdesigners Posted February 13, 2015 Share Posted February 13, 2015 I have to select first state, then display cities, shops under that state, some times some states does not have cities. If no cities found I do not want to show that rows or city. Something life below. Florida (field - state) Tempa - Macys Miami - Officemax Okala - Staptes Oklahoma (field - state) .... ..... In this case I do not want to see Oklahoma. can some one help me please. Thanks, Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted February 13, 2015 Share Posted February 13, 2015 Think you got a loop going on with the multiple posts! Why don't you just not display the record if it doesn't exist? Quote Link to comment Share on other sites More sharing options...
cowboysdude Posted February 13, 2015 Share Posted February 13, 2015 (edited) Well if you're doing a foreach loop then tell it to not display for example... if (!empty($game['vtn'])) That is just an example I used in my module to not display vtn.. I didn't want to display a zero so I used that... You can always do a, again not sure if you're looping but if you are I don't know the keys so this is just an example... if ($games['vtn'] != "Oklahoma") { show your content here... } I'm no expert but that should work.... You're not real specific on whether you don't ever want to show it or just one time... the above method will never show it. Edited February 13, 2015 by cowboysdude Quote Link to comment Share on other sites More sharing options...
hcdesigners Posted February 19, 2015 Author Share Posted February 19, 2015 Thank you for your input. Not helping. Please see below my code, very messy, not in order, I have all the way below displayed date. Automatically I want to display country, under country state, then under state each city, population, schools, school url.. I do not want to physically code country or state like, != state, etc.. I tried pasting my code, I could not. Please see attachment. Help me out in looping this this please. Thank you, ---------------- phpcode-phpfreaks-loop.txt Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 19, 2015 Share Posted February 19, 2015 Since I don't look at code that is not posted here, I will offer this solution. Why not build a query of what you need for your output and only select the records that meet your needs? That way you will not have any record for a state that does not have associated cities/stores. Quote Link to comment Share on other sites More sharing options...
hcdesigners Posted February 19, 2015 Author Share Posted February 19, 2015 Please click on attachment txt file for code. Modify it if you can please, let me know. I am not that good with php/MySQL, learning. Thanks, Quote Link to comment Share on other sites More sharing options...
ginerjm Posted February 19, 2015 Share Posted February 19, 2015 As I already said - I don't look at attached code - only that which is posted (correctly) on this forum. 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.