Advertisement:

Author Topic: Display all images (not only one) in admin based on Item ID  (Read 278 times)

butterfly

  • Jr. Member
  • **
  • Posts: 80
Display all images (not only one) in admin based on Item ID
« on: December 17, 2018, 05:53:10 pm »
Hi

I want display all images based on Item ID, e.g = 1000;

This query do it (almost):
Code: [Select]
$query = $conn->osc_dbFetchResult("SELECT s_path, pk_i_id, s_extension FROM /*TABLE_PREFIX*/_t_item_resource WHERE fk_i_item_id = 1000 );

//path to image in admin
$img_path = $query['s_path']. $query['pk_i_id']. $query['s_extension'];
Almost, because if Item has more than 1 photo, it return the fist one, but not all!

How to rebuild this query to get all photos?

Web-Media

  • Sr. Member
  • ****
  • Posts: 453
  • Web
Re: Display all images (not only one) in admin based on Item ID
« Reply #1 on: December 17, 2018, 10:00:27 pm »
foreach "querry " as q will do the job

WEBmods

  • Hero Member
  • *****
  • Posts: 937
  • github.com/webmods-croatia/love-osclass/ | patrick
Re: Display all images (not only one) in admin based on Item ID
« Reply #2 on: December 18, 2018, 03:38:19 pm »
Hello,

Using the DAO class will help:

Code: [Select]
<?php
$dao 
= new DAO(); // Initialise DAO class
$query $dao->dao->query("SELECT s_path, pk_i_id, s_extension FROM /*TABLE_PREFIX*/_t_item_resource WHERE fk_i_item_id = 1000"); // Select the data
if(count($query) > 0) {
    
$result $query->result(); // Fetch array
    
foreach($result as $image) { // Parse array
        
$full_path $image['s_path'].$image['pk_i_id'].$image['s_extension'];
        
// Do something with the path, ie. echo it.
    
}
}

Regards.