SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Feb 2004
    Location
    UK
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call images rather than text, works in one part of site not the other

    Hello

    On my site I list hotels, the hotels have various facilites attached to them, on the listings page these facilites are shown as icons representing each facility, in the index for each region the facilites are listed as text, I have been trying to get the index pages to also show the icons but cannot get them to display.

    The code that is in the listing page that works correctly is below, it seems to work by having the name of the facility the same as the image name in .gif format, this code also calls nearby facilities, facilities and hotel types

    PHP Code:
    $arr = array('item_types''facilities''nearby_facilities'); 
            foreach(
    $arr as $key => $val) { 
                
    $sql_items $this->db->QFetchRowArray("SELECT * FROM {$this->tables['fields']} WHERE (field='{$val}') ORDER BY id ASC;");
                
               if (
    $val == 'nearby_facilities'$miles explode(','$this->currentItem['nearby_miles']);
               
    $arr_items = array(); 
                foreach(
    explode(','$this->currentItem[$val]) as $key_item => $val_item) {
                     if (!empty(
    $val_item) && !empty($sql_items[$key_item]['value'])) {
                         if (
    $val == 'nearby_facilities') if ($miles[$key_item] == 1array_push($arr_items$sql_items[$key_item]['value'] . ' - ' $miles[$key_item] . ' Mile');
                         else 
    array_push($arr_items$sql_items[$key_item]['value'] . ' - ' $miles[$key_item] . ' Miles');
                         else 
    array_push($arr_items$sql_items[$key_item]['value']);
                     } 
                } 
                if (
    $val == 'nearby_facilities'$this->currentItem[$val] = implode('<br />'$arr_items);
                 else if (
    $val == 'facilities') { 
                    
    sort($arr_items); 
                    foreach(
    $arr_items as $key_item => $val_item) { 
                        
    $val_item_img str_replace("'"''$val_item); 
                        
    $val_item_img str_replace(chr(146), ''$val_item_img); 
                        
    $image strtolower(str_replace(' ''_'$val_item_img)) . '.gif';
                         
    $arr_items[$key_item] = "<div class='list_facilities_img'><img src='_layouts/images/facilities/{$image}' alt='$val_item' /> $val_item</div>";
                    } 
                    
    $this->currentItem[$val] = implode(''$arr_items); 
                } 

    The code below is the code to call the facilities in the index pages, this shows the facilities but in text format, i have tried just replacing with the above that relates to the facilities but it fails to show, it just displays a series of 1 and 0's

    PHP Code:
            $facilities '';
            
    $sql_items $this->db->QFetchRowArray("SELECT * FROM {$this->tables['fields']} WHERE (field='facilities') ORDER BY id ASC;");
            
    $arr_items = array();
            foreach(
    explode(','$vars['facilities']) as $key_item => $val_item
            if (!empty(
    $val_item) && !empty($sql_items[$key_item]['value'])) array_push($arr_items$sql_items[$key_item]['value']);
            
    $vars['facilities'] = implode(', '$arr_items);
            if (!empty(
    $vars['facilities'])) $vars['facilities'] = ' ' $vars['facilities'];
            else 
    $vars['facilities'] = '';
            
            
            else if (
    $val == 'facilities') {
            
    sort($arr_items); 
    Thanks John

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,747
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    So what's stored in the table where the field type is facilities?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Member
    Join Date
    Feb 2004
    Location
    UK
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    So what's stored in the table where the field type is facilities?
    1 or 0 for example 0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,0,0,0,1,0,0,1,1,1,1,0,0 each one relating to the facility in question, 1 being yes its available 0 being not, no image is served if not available

  4. #4
    SitePoint Member
    Join Date
    Feb 2004
    Location
    UK
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anybody give me some help with this please?

    Thanks John


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •