Jump to content

Displaying data maybe a loop??


deeej

Recommended Posts

Hi people, not a clue how I would do this if someone could help that would be great, I tried putting all the information in a table but if there is no value some of the data is displayed randomly!

 

if ($1[pool]=="y") { $ShowInfo .= "<tr><img src='images/icons/pool.gif'><B> Pool</B></tr>"; }
        if ($1[valet]=="y") { $ShowInfo .= "<tr><img src='images/icons/valet.gif'><B> Valet</B></tr>"; }
        if ($1[gym]=="y") { $ShowInfo .= "<tr><img src='images/icons/gym.gif'><B> Gym</B></tr>"; }
        $ShowInfo .= "<tr><img src='images/icons/beds.gif'><B> $a1[beds] Beds</B></tr>";
        $ShowInfo .= "<tr><img src='images/icons/checkin.gif'><B> Check-In Time:</B> $1[checkintime]</tr>";
        $ShowInfo .= "<tr><img src='images/icons/checkout.gif'><B> Check-Out Time:</B> $1[checkouttime]</tr>";
        if ($1[parking]=="y") { $ShowInfo .= "<tr><img src='images/icons/parking.gif'><B> Parking</B></tr>"; }
        if ($1[wireless]=="y") {  $ShowInfo .= "<tr><img src='images/icons/wireless.gif'><B> Wireless</B></tr>"; } 

 

basically I have a database full off businesses and each business has a list of extra facilities.

 

What I am trying to do is to display the facilities they do have, and not the ones they do not have.

 

like so:

 

Extra facility 1, extra facility 2

extra facility 3, extra facility 4

extra facility 5, extra facility 6

 

2 Facilities on each row then go to a new line I tried a table but if they do not have 'for example facility 3' then there is a gap where it should be in the table and data looks odd.

 

This is mysql and PHP.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/61380-displaying-data-maybe-a-loop/
Share on other sites

1 ) variable names beginning with a number ($1) are not allowed.

 

2 ) string keys ([valet]) should be quoted (['valet'])

 

3 ) Does the number of beds come from different source ($a1['beds'])

 

4 ) How are you getting the $1[xxx] data in the first place?

Sorry the php code works fine I just changed it a bit, it is all a1.. (it's getting it to display how I want I am having trouble with I was showing the code I want to change to display correct)

 

Try reading it again (I am a bit of a n00b sorry lol) I showed an example of how I want it to display but I only want data shown if they have that facility, the values are enum ('y','n') and some are numbers (like amount of rooms a hotel has), obviously if they do not have the facility I do not want it to display This bit I can get working fine.

 

It's just to display the data in a table with 2 columns with out the data having random spaces if they do not have that facility.

 

Example 1, Example 2

            , Example 3

Example 4, Example 5

 

Thanks,

 

Hope you can understand now!!! Sorry

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.