Php Smarty MYSQL阵列关联id

Php Smarty MYSQL阵列关联id,php,mysql,arrays,smarty,Php,Mysql,Arrays,Smarty,我的php代码如下所示: $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

我的php代码如下所示:

$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->assign('products_images',$products_images);
这样就形成了这样一个数组

Array ( 
    [info] => array (
        [id] = 1
        [name] = abc
    ) 
    [images] => array (
        [Products_Image_Thumb] = 1a.jpg
        [Products_Image_Big] = 1b.jpg
    )
)
但我无法使用smarty获取图像信息:

{foreach from=$products_images key=cols item=image name=images}
{if $cols % 4 == 0}<div>{/if}
<a href="images/products/big/{$image.images.Products_Image_Big}">
<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;" /></a>
{if $cols % 4 == 3}</div>{/if}
{if $smarty.foreach.images.last}</div>{/if}
{/foreach}  
{foreach from=$products\u images key=cols item=image name=images}
{if$cols%4==0}{/if}
{if$cols%4==3}{/if}
{if$smarty.foreach.images.last}{/if}
{/foreach}

谢谢你的帮助

根据我之前回答的评论,这应该行得通。然而,它是未经测试的,我已经有一段时间没有使用Smarty了

{foreach from=$products_images key=cols item=product name=products}
    {if $cols % 4 == 0}<div>{/if}
    {foreach from=$product.images item=image name=images}
        <a href="images/products/big/{$image.Products_Image_Big}">
        <img src="images/products/thumb/{$image.Products_Image_Thumb}" alt="Click to Enlarge" title="Click to Enlarge" width="87" height="65" style="margin:3px;" /></a>
    {/foreach}
    {if $cols % 4 == 3}</div>{/if}
    {if $smarty.foreach.products.last}</div>{/if}
{/foreach}
{foreach from=$products\u images key=cols item=product name=products}
{if$cols%4==0}{/if}
{foreach from=$product.images item=image name=images}
{/foreach}
{if$cols%4==3}{/if}
{if$smarty.foreach.products.last}{/if}
{/foreach}

Gallery\u Image\u Big和Gallery\u Image\u Thumb才是真正的钥匙。。。我只是在做一个例子,我猜图像没有显示,你希望它们显示出来,对吗?还是另一个问题?我不知道你的意思是什么,我无法用smarty获得图像信息。是的,图像没有显示,在{$image.images.Gallery\u image\u Big}中没有任何内容正在打印好的,如果你只是在foreach循环数组([info]=>Array([id]=>1[Product\u Title]=>Caterpilla)中放置一个
{$image | print\r}
,你能告诉我输出是什么吗[Product\u URL]=>Caterpilla[Product\u Size]=>Null[Product\u Suit]=>Children[Product\u Cover]=>1[Product\u Description]=>Test Castle[Product\u Price]=>50[Product\u OPrice]=>Null[Image]=>Array([0]=>Array([id]=>3[Product\u id]=>1[Product\u Image\u Thumb]=>Thumb]=>Thumb\u 56\u Sam.jpg[Product\u Image\u Big]=>Big]))