oK no problem. I will explain and feel free to ask me if you need more information or explaination.
I can not post here the hole code of details (it is very big). That why I made for you onother example.
In a custom page I want some information from the table EVENTS.
On events.php you find als results the information of the events + the foto of this events.
Because not all the events has a foto I used the FUNCTION ISSET to show a thumb (thumb.jpg) if the events has a foto or show the thumb (thumb_no) if the events has no foto.
I use this code on the events.php:
$events_thumb = "<a href=\"".$site_sess->url(ROOT_PATH."events".$events_row['events_id']).".php \" target=\"_blank\"><img src=\"".$site_sess->url(ROOT_PATH."images/events/thumb".$events_row['events_id']).".jpg\" width=\"120\" height=\"80\" border=\"0\" alt=\"".$events_row['events_name']."\" />";
$events_thumb_no = "<a href=\"".$site_sess->url(ROOT_PATH."events".$events_row['events_id']).".php \" target=\"_blank\"><img src=\"".$site_sess->url(ROOT_PATH."images/events/geen_thumb.jpg")."\") width=\"120\" height=\"80\" border=\"0\" alt=\"".$events_row['events_name']."\" />";
$foto_url = $site_sess->url(ROOT_PATH."images/events/thumb".$events_row['events_id']).jpg;
$thumb = (isset($foto_url)) ? $events_thumb : $events_thumb_no;
NOTE: $foto_url IS NOT STORED in database (table events), otherwise it will be easy to solve this problem.
Here is the code of the events.php:
<?php
$main_template = substr(($_SERVER['PHP_SELF']),0,7);
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$allowed_users_access_page = array(substr(($_SERVER['PHP_SELF']),8,-4)); // Change for all user ID need.
if (function_exists('check_for_valid_user_access_page') && !check_for_valid_user_access_page($allowed_users_access_page) && $user_info['user_level'] < ADMIN) {
redirect($url);
}
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
include(ROOT_PATH.'includes/stats.php');
//-----------------------------------------EVENTS--------------------------------------------------------------------
$additional_sql = "";
$additional_sql_array = array();
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
foreach ($additional_user_fields as $key => $val) {
$additional_sql = ", u." . $key;
$additional_sql_array[] = $key;
}
}
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
foreach ($additional_user_fields as $key => $val) {
$additional_sql .= ", u.".$key;
}
}
$sql = "SELECT i.image_id, i.image_thumb_file, i.image_media_file, e.events_id, e.events_thumb, e.events_name, e.events_description, e.events_datum1, e.events_adres, e.events_prijzen, e.events_betaling, e.events_contact, e.events_image_id, e.events_user_id, i.cat_id, i.user_id, i.image_name, i.image_date, i.image_active, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
FROM (".EVENTS_TABLE." e, ".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_id = e.events_id
GROUP BY e.events_id
ORDER BY i.image_datum ASC";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$events = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>".$lang['no_foto']."</td></tr>";
}
else {
$events = "<table class=\"head2\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">
";
while ($events_row = $site_db->fetch_array($result)){
//-----Here is my request
$events_thumb = "<a href=\"".$site_sess->url(ROOT_PATH."events".$events_row['events_id']).".php \" target=\"_blank\"><img src=\"".$site_sess->url(ROOT_PATH."images/events/thumb".$events_row['events_id']).".jpg\" width=\"120\" height=\"80\" border=\"0\" alt=\"".$events_row['events_name']."\" />";
$events_thumb_no = "<a href=\"".$site_sess->url(ROOT_PATH."events".$events_row['events_id']).".php \" target=\"_blank\"><img src=\"".$site_sess->url(ROOT_PATH."images/events/geen_thumb.jpg")."\") width=\"120\" height=\"80\" border=\"0\" alt=\"".$events_row['events_name']."\" />";
$foto_url = $site_sess->url(ROOT_PATH."images/events/thumb".$events_row['events_id']).jpg;
$thumb = (isset($foto_url)) ? $events_thumb : $events_thumb_no;
/*
if (empty($thumb_url)) {
$thumb = $events_thumb_no;
}
else {
$thumb = $events_thumb;
}
*/
$events .= "<tr>
<td valign=\"top\">".$thumb."</td></tr>
";
}
}
$events .= "</table>\n";
$site_template->register_vars("events", $events);
unset($events);
//----------------------------------------------------------------------------
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator']."Events pagina"."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"clickstream" => $clickstream,
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
So my question is: Why when I use ISSET I get A NOT EXISTING THUMB with the events who has no foto?
I think I have to use here another fuction!!!!!!!