Jump to content

loop select records


hcdesigners

Recommended Posts

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,

 

Link to comment
https://forums.phpfreaks.com/topic/294565-loop-select-records/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/294565-loop-select-records/#findComment-1505589
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/294565-loop-select-records/#findComment-1506137
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/294565-loop-select-records/#findComment-1506141
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.