我必須顯示最近上傳的圖片,但只有第一個條目不斷顯示,這是我們擁有的最早的圖片。我們的數據庫是建立這樣的:顯示來自PHP表格的最新年份
jos_campaigns_children
campaign_id | child_id | code | 1921 | 1921 | GTM-0103-A00627 |
jos_campaigns_children_detail
detail_id | child_year | campaign_id | 5788 | 2013 | 1920 | 1921 | 2011 | 1921 | 3656 | 2012 | 1921 | 5789 | 2013 | 1921 | 1922 | 2011 | 1922 |
HTML代碼源:
<img src="/child_images/<?php echo $row_children_list[code]; ?>-<?php echo $row_children_list[child_year]; ?>-S-1.jpg"
當前HTML輸出:
<img src="/child_images/GTM-0103-A00627-2011-S-1.jpg"
所需的輸出:
<img src="/child_images/GTM-0103-A00627-2013-S-1.jpg"
我只是不知道語法用,使其僅顯示最近一年來代替$row_children_list[child_year]
。
下面是我找到的查詢(這是別人的代碼,所以我並不確切地知道我在做什麼:))
$query_children_list = "SELECT * FROM `jos_campaigns_children` a, `jos_regions` b, jos_campaigns_children_detail c WHERE (a.published ='1' and a.old_sponsor_id = '' and a.region_id = b.id and a.paypal_profile_status = '0' and a.campaign_id = c.campaign_id)" . $age_query . "" .$gender_query . "" . $location_query . " GROUP BY a.child_id ORDER BY a.campaign_id DESC LIMIT " . $starting_row . ", " . $row_per_page . "";
$result_children_list = mysql_query($query_children_list);
你的查詢在哪裏? –
你如何建立'$ row_children_list []'? – paqogomez
我可以建議'where child_year = max(child_year)'沒有查詢查看 –