Hi,
I did a lot of work to have a related images on the details page, but there is a small conflict in this page.
I explain:
On my galery I have 2 gategories:
1- videos of the soccer players
2- Foto's of the soccer players
For example:
I have 4 videos of RONALDINHO en one (1) foto for this player
On the details.html of the foto of RONALDINHO I want to show also all his video's under (Thumbs ofcourse).
I added a new database field: image_player
That means the name of the player.
I used this code on the details.php:
//-----------------------------------------------------
//----------------------------------------BEGIN SHOW RELATED PLAYER IMAGES----------------------------------------------
//-----------------------------------------------------
$image_speler = format_text($image_row['image_speler'], 2);
$image_name = format_text($image_row['image_name'], 2);
//i.image_speler = '$image_name'
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_player = '$image_name'
GROUP BY i.image_id
ORDER BY i.image_name ASC";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$related_speler_images = "<table class=\"head3\" width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
$related_speler_images .= $lang['no_videos'];
$related_speler_images .= "</td></tr></table>";
}
else {
$related_speler_images = "<table class=\"video_bekeken\" width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
$count = 0;
$bgcounter = 0;
while ($image_row = $site_db->fetch_array($result)){
if ($count == 0) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$related_speler_images .= "<tr class=\"video_bekeken\">\n";
}
$related_speler_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
show_image($image_row);
$related_speler_images .= $site_template->parse_template("thumbnail_bit");
$related_speler_images .= "\n</td>\n";
$count++;
if ($count == $config['image_cells']) {
$related_speler_images .= "</tr>\n";
$count = 0;
}
} // end while
if ($count > 0) {
$leftover = ($config['image_cells'] - $count);
if ($leftover >= 1) {
for ($f = 0; $f < $leftover; $f++) {
$related_speler_images .= "<td width=\"".$imgtable_width."\">\n \n</td>\n";
}
$related_speler_images .= "</tr>\n";
}
}
$related_speler_images .= "</table>\n";
}
$site_template->register_vars("related_speler_images", $related_speler_images);
unset($related_speler_images);
//-----------------------------------------------------
//----------------------------------------END SHOW RELATED PLAYER IMAGES----------------------------------------------
//-----------------------------------------------------
More explaination:
WHERE i.image_player = '$image_name'
That means that the code see first the name of the image (foto): RONALIDNHO and then it wil get all the related images who has: i.image_player = RONALDINHO.
This code works almost perfect, but there is a problem:
1- If I use this code in the begining of the details.php, you get to see: The wright image + the wrong related videos.
2- If I use this code in the end of the details.php, you get to see: The wrong image + the WRIGHT related videos (Thumbs)
Thank you in advance,
Cruxy