Author Topic: How many people added that image to lightbox - but how?  (Read 3505 times)

0 Members and 1 Guest are viewing this topic.

Offline pjotrek

  • Newbie
  • *
  • Posts: 24
    • View Profile
How many people added that image to lightbox - but how?
« on: September 26, 2012, 05:11:26 PM »
Hello everybody

I'd like to display under thumbnail on main page a number that display how many people added this photo to lightbox. It's not difficult becouse the mysql query looks like that :

SELECT count(*) from 4images_lightboxes where lightbox_image_ids = for example 1;

But how will look function that display that number ? And where should be placed - in functions.php or other file ?

Please help.


Rembrandt

  • Guest

Offline pjotrek

  • Newbie
  • *
  • Posts: 24
    • View Profile
Re: How many people added that image to lightbox - but how?
« Reply #2 on: September 27, 2012, 08:33:39 AM »
Thank You Rembrandt !

Can You please tell me where should I paste the code if I want to display the number of users under all thumbnails ? Becouse I dont want to show it on details page but under every thumbnail on list page.

$sql "SELECT l.lightbox_image_ids, u.user_id, l.user_id".get_user_table_field(", u.""user_name")."
	
	
	
	
FROM ("
.LIGHTBOXES_TABLE." l, ".USERS_TABLE." u)
	
	
	
	
WHERE l.lightbox_image_ids LIKE '%
$image_id%' AND u.user_id=l.user_id";
	
	
	
	

$result $site_db->query($sql);
  
$lightbox_row = array();
  while (
$row $site_db->fetch_array($result)) {
    
$lightbox_row[] = $row;
  }
  
$site_db->free_result($result);
  
$num_rows sizeof($lightbox_row);
	
if (
$num_rows) {
    for (
$i 0$i $num_rows$i++) {
	
	
	
$lightbox_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$lightbox_row[$i]['user_id'])."\">".$lightbox_row[$i]['user_name']."</a>";
	
	
	
if (
$i+!= $num_rows) {
	
	
	
	
$lightbox_list .= ", ";
	
	
	
}
	
	
	

	
	
}
	
}

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
	
"lightbox_list" => $lightbox_list,


By the way  I think that this solution will not be good because when mysql will have to search LIKE %image_id% for example 1000 records the database will die....I will try do it by adding new field in database to image table for example 4images_image.lightbox and by using UPDATE command I will add "+1" counter.

I don't know if it works but it will be much better solution in my opinion.

Maybe You can help me ?

Thanks again!
« Last Edit: September 30, 2012, 07:50:43 AM by Rembrandt »