diff options
Diffstat (limited to '')
-rw-r--r-- | admin/update.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/admin/update.php b/admin/update.php index 817a67aae..10813349e 100644 --- a/admin/update.php +++ b/admin/update.php @@ -514,6 +514,22 @@ INSERT INTO '.IMAGE_CATEGORY_TABLE.' '.implode(',', $ids).' ;'; pwg_query($query); + + // set a new representative element for this category + $query = ' +SELECT image_id + FROM '.IMAGE_CATEGORY_TABLE.' + WHERE category_id = '.$category_id.' + ORDER BY RAND() + LIMIT 0,1 +;'; + list($representative) = mysql_fetch_array(pwg_query($query)); + $query = ' +UPDATE '.CATEGORIES_TABLE.' + SET representative_picture_id = '.$representative.' + WHERE id = '.$category_id.' +;'; + pwg_query($query); } return $output; } |