Ok then, I will explain:
I want to have some information from the users table in database.
I want to call the HOBBY of the user.
So the query is: give me as results the hobby of the uder_id=XXX.
On my custom page i use this query, but I think it is not complete or wrong:
$sql = "SELECT i.image_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 (".USERS_TABLE." u, ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
WHERE i.user_id = 2
ORDER BY i.user_id DESC
LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
Here is the code of my custom page:
<?php
$main_template = 'special3';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$allowed_users_access_page = array(2); // 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');
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
//Hobby
$sql = "SELECT i.image_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 (".USERS_TABLE." u, ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
WHERE i.user_id = 2
ORDER BY i.user_id DESC
LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows) {
$hobby = $lang['no_images'];
}
else {
$hobby = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>User Name</td><td></td><td>User hobby</td></tr>";
while ($user_row = $site_db->fetch_array($result)){
$hobby .= "<tr><td>".$user_row['user_name']."</a></td><td>".$user_row['user_hobby']."</td</td></tr>";
}
}
$hobby .= "</table>\n";
$site_template->register_vars("hobby", $hobby);
unset($hobby);
On my custom page I get 20 users (inclusief GUEST) [b](This is wrong because I asked fot the user_id = 2)[/b] and nothing about the hobby. [b](The hobby field stays empty)[/b]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator']."Special"."</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');
?>
Can you see what I did wrong?
Let me know if you need more info from me.
Thanks in advance