Author Topic: put all photos added by user to detail.html  (Read 7173 times)

0 Members and 1 Guest are viewing this topic.

Offline bazalt

  • Newbie
  • *
  • Posts: 13
    • View Profile
put all photos added by user to detail.html
« on: August 19, 2007, 07:12:27 AM »
How can I make to put all photos added by user to detail.html? I`ve added {user_profile_images} to detail.html but nothing happens :(

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
put all photos added by user to detail.html
« Reply #1 on: August 19, 2007, 03:44:35 PM »
In details.php file,

find:

Quote
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------

add before:

Quote
//-----------------------------------------------------
//--- START Show user images in profile ---------------
//-----------------------------------------------------
$imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
if ((substr($config['image_table_width'], -1)) == "%") {
  $imgtable_width .= "%";
}

$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;
  }
}


$sql = "SELECT COUNT(*) as user_count_images
        FROM ".IMAGES_TABLE."
        WHERE user_id = $user_id";
        $row = $site_db->query_firstrow($sql);
        $user_total_images = $row['user_count_images'];

$site_template->register_vars("user_total_images", $user_total_images);
unset($user_total_images);

$user_images = 20; // SET HERE HOW MUCH IMAGES SHOULD BE SHOWN
$sql = "SELECT COUNT(i.user_id) AS images
        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_active = 1 AND c.cat_id = i.cat_id AND i.user_id = $user_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";
  $result = $site_db->query_firstrow($sql);
  $num_images = $result['images'];
$site_db->free_result();
$num_rows_all = (isset($num_images)) ? $num_images : 0;
$link_arg = $site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=$user_id");
include(ROOT_PATH.'includes/paging.php');
$getpaging = new Paging($page, $user_images, $num_rows_all, $link_arg);
$offset = $getpaging->get_offset();
$site_template->register_vars(array(
"paging" => $getpaging->get_paging(),
"paging_stats" => $getpaging->get_paging_stats()
));

$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")."
        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_active = 1 AND c.cat_id = i.cat_id AND i.user_id = $user_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
        ORDER BY i.image_date DESC
        LIMIT $offset, $user_images";

$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);

if (!$num_rows)  {
  $user_profile_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
  $user_profile_images .= $lang['no_new_images'];
  $user_profile_images .= "</td></tr></table>";
}
else  {
  $user_profile_images = "<table 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;
      $user_profile_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
    }
    $user_profile_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";

    show_image($image_row);
    $user_profile_images .= $site_template->parse_template("thumbnail_bit");
    $user_profile_images .= "\n</td>\n";
    $count++;
    if ($count == $config['image_cells']) {
      $user_profile_images .= "</tr>\n";
      $count = 0;
    }
  } // end while
 
  if ($count > 0)  {
    $leftover = ($config['image_cells'] - $count);
    if ($leftover >= 1) {
      for ($f = 0; $f < $leftover; $f++) {
        $user_profile_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
      }
      $user_profile_images .= "</tr>\n";
    }
  }
  $user_profile_images .= "</table>\n";
} // end else

$site_template->register_vars("user_profile_images", $user_profile_images);
unset($user_profile_images);
//-----------------------------------------------------
//--- END Show user images in profile -----------------
//-----------------------------------------------------

In details.html file, try {user_profile_images} . Should work. ;)
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 bazalt

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: put all photos added by user to detail.html
« Reply #2 on: August 20, 2007, 03:50:52 AM »
 :(

Code: [Select]
DB Error: Bad SQL Query: SELECT COUNT(*) as user_count_images FROM 4images_images WHERE user_id =
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 '' at line 3

DB Error: Bad SQL Query: SELECT COUNT(i.user_id) AS images FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = AND i.cat_id NOT IN (0)
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 'AND i.cat_id NOT IN (0)' at line 4

DB Error: Bad SQL Query: 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, i.image_aboutme, i.image_realname, i.image_birthday, i.image_interests, i.image_network, i.image_chatnick, i.image_chatchan, i.image_icq, i.image_email, i.image_phone, i.image_aboutlove, i.image_aboutpet, i.image_petname, i.image_petbreed, i.image_petage, i.image_aboutavto, i.image_avtomodel, i.image_avtoyear, i.image_aboutvirt, i.image_virtgame, i.image_aboutprotest, c.cat_name, u.user_name FROM (4images_images i, 4images_categories c) LEFT JOIN 4images_users u ON (u.user_id = i.user_id) WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = AND i.cat_id NOT IN (0) ORDER BY i.image_date DESC LIMIT 0, 20
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 'AND i.cat_id NOT IN (0) ORDER BY i.image_date DESC LIMIT 0, 20' at line 4

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\www\people\includes\db_mysql.php on line 116

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: put all photos added by user to detail.html
« Reply #3 on: August 20, 2007, 03:57:47 AM »
Ok, correct.

Change:

Quote
WHERE user_id = $user_id";

for:

Quote
WHERE user_id = " . $image_row['user_id'];

and:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = $user_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";

for:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = " . $image_row['user_id'] . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";

and:

Quote
$link_arg = $site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=$user_id");

for:

Quote
$link_arg = $site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=" . $image_row['user_id']);

and:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = $user_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")

for:

Quote
WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.user_id = " . $image_row['user_id'] . " AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")

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 bazalt

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: put all photos added by user to detail.html
« Reply #4 on: August 20, 2007, 05:35:02 AM »
thunderstrike, thnx, now there no mysql-errors.

But now it shows 404 error instead of photo, and Guest instead of nick of photo-owner :(

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: put all photos added by user to detail.html
« Reply #5 on: August 20, 2007, 01:55:35 PM »
Ok, so ask author of MOD.
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 thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
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 ?