Author Topic: Using image tags on a custom page.  (Read 66974 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #60 on: November 14, 2007, 10:44:44 PM »
Oke, almost done.

The additional user field Hobby is now showing, but in my query I ask only for the hobby of the user_id = 2 (not for the first 20 users 'LIMIT 20";').

The results was 20 users with their hobbies.

I think we have to fix the query:

Code: [Select]
$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);

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #61 on: November 14, 2007, 10:47:47 PM »
Change:

Code: [Select]
$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);

for:

Code: [Select]
$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 (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = i.user_id)
        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);
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #62 on: November 14, 2007, 10:56:59 PM »
Now I get the same user (+hobby) 20 times instead of 1 time!

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #63 on: November 14, 2007, 11:00:40 PM »
Please post full code in bbcode.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #64 on: November 14, 2007, 11:09:03 PM »
Code: [Select]
<?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;
  }
}

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;
   }
}

 
//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 ("
.IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN " 
USERS_TABLE " u ON (" get_user_table_field("u.""user_id") . " = i.user_id)
        WHERE i.user_id = 1
        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>".format_text(trim($user_row[$user_table_fields['user_name']]), 2)."</a></td><td>".$user_row['user_hobby']."</td</td></tr>";


  
$hobby .= "</table>\n";
$site_template->register_vars("hobby"$hobby); 
unset(
$hobby);

//-----------------------------------------------------
//--- 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');
?>

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #65 on: November 14, 2007, 11:14:27 PM »
Ok so if want for show user name and hobby only for upload user - is this:

Code: [Select]
$sql = "SELECT " . get_user_table_field("u.", "user_name") . $additional_sql . "
        FROM ".IMAGES_TABLE." i
        LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = i.user_id)
        WHERE i.user_id = 1
        GROUP BY i.user_id
        ORDER BY i.user_id DESC
        LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
« Last Edit: November 14, 2007, 11:34:53 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #66 on: November 14, 2007, 11:26:48 PM »
I get this error:

Quote
DB Error: Bad SQL Query: SELECT , u.user_name....
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' u.user_name, i.image..at line 1

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #67 on: November 14, 2007, 11:28:54 PM »
This is right - post edit.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #68 on: November 14, 2007, 11:32:38 PM »
The same error again!!

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #69 on: November 14, 2007, 11:34:07 PM »
Ok try now.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #70 on: November 14, 2007, 11:42:28 PM »
Perfect for upload users :), but what about the normal users? (They did not upload anything)
Can I use the same query?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #71 on: November 14, 2007, 11:45:15 PM »
I no get ... full detail ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #72 on: November 14, 2007, 11:55:25 PM »
You said:

Quote
Ok so if want for show user name and hobby only for upload user - is this:

only for upload user, I understand that this query look ONLY for the users hoe upload images to the gallery. right?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #73 on: November 15, 2007, 12:02:36 AM »
Yes ... this is right ... but no get new question ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #74 on: November 15, 2007, 12:08:16 AM »
Oke, listen:

You are a user on my gallery and you have NEVER uploaded an image in this gallery. Clear?

If I use this query to look for the hobby of Thunderstrike. Do I get as results your name and your hobby?
Do not forget, you have NEVER NEVER uploaded an image into my gallery?