aboutsummaryrefslogtreecommitdiffstats
path: root/admin/update.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/update.php')
-rw-r--r--admin/update.php16
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;
}