Note that there are some explanatory texts on larger screens.

plurals
  1. POSmarty MYSQL Array assoc id
    text
    copied!<p>I have my php code like this:</p> <pre><code>$products = mysql_query("SELECT p.* FROM products AS p " ."INNER JOIN products_cat_link AS cpl ON cpl.Product_ID = p.id " ."WHERE cpl.Category_ID = '$forcat' " ."ORDER BY p.id"); $products_row = array(); $products_images = array(); while($prow = mysql_fetch_assoc($products)) { if (isset($prow['id'])) { $product['info'] = $prow; $images = mysql_query("SELECT * FROM products_images WHERE `Product_id` = '$prow[id]' ORDER BY id"); while($irow = mysql_fetch_assoc($images)) { $images_result[] = $irow; } $product['images'] = $images_result; $products_images[] = $product; } $product = ''; $images_result = ''; } $smarty-&gt;assign('products_images',$products_images); </code></pre> <p>That makes an array like this</p> <pre><code>Array ( [info] =&gt; array ( [id] = 1 [name] = abc ) [images] =&gt; array ( [Products_Image_Thumb] = 1a.jpg [Products_Image_Big] = 1b.jpg ) ) </code></pre> <p>But i cannot get the images information with smarty:</p> <pre><code>{foreach from=$products_images key=cols item=image name=images} {if $cols % 4 == 0}&lt;div&gt;{/if} &lt;a href="images/products/big/{$image.images.Products_Image_Big}"&gt; &lt;img src="images/products/thumb/{$image.images.Products_Image_Thumb}" alt="Click to Enlarge" title="Click to Enlarge" width="87" height="65" style="margin:3px;" /&gt;&lt;/a&gt; {if $cols % 4 == 3}&lt;/div&gt;{/if} {if $smarty.foreach.images.last}&lt;/div&gt;{/if} {/foreach} </code></pre> <p>Thanks for any help!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload