Page 1 of 1

Query user_id to album_id to match and get pass hidden field

Posted: Wed Mar 02, 2011 5:05 pm
by danjapro
Need to get the album_id, so I can pass it into URL for other pages to read.

I am using this function and two tables to match the session user with (user_id with album_id for that user)
if they have no Id return "Album_id=0"??

How would I finish the code to get the album_id to echo or print on any textfield or hidden field??

Code: Select all

	//function check_album_on($album_id){
		
		if(!$album_id) return true; // everybody can add an album if is a registered /author user
		
		$db =& JFactory::getDBO();
		$user =& JFactory::getUser();
		$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
		$db->setQuery($query);
		$album_creator = $db->loadResult();
		
		if($album_creator == $user->id) return true;
		else return false;
                          echo ".$album_id" or echo
		
	}

Re: Query user_id to album_id to match and get pass hidden f

Posted: Thu Mar 03, 2011 11:15 am
by danjapro
Can Anyone look at the String above and direct me to hwo would I go about gathering and collection only the AblumId and passing it for Hidden fields or url etc..
This is the code I am trying to use to get the information I need.Please help me.

Code: Select all

   function check_album_on($album_id){
      
      if(!$album_id) return true; // everybody can add an album if is a registered /author user
      
      $db =& JFactory::getDBO();
      $user =& JFactory::getUser();
      $query = 'SELECT user_id, id, format_id, date FROM #__muscol_albums WHERE id = ' . $album_id ;
      $db->setQuery($query);
      $album_creator = $db->loadResult();
      
      if($album_creator == $user->id) return true;
      else return false;
                          echo ".$album_id" or echo
      
   }

Re: Query user_id to album_id to match and get pass hidden f

Posted: Thu Mar 03, 2011 3:29 pm
by danjapro
Can you tell me if this will return the album_id that marches the user ID and allow me to echo that ID

Code: Select all

			$user =& JFactory::getUser();
			
	$id = JRequest::getVar( 'id' ) ;
	$view = JRequest::getVar( 'view' ) ;
			
	$params = &JComponentHelper::getParams( 'com_community' );
		$itemid = $params->get('itemid');
		   if($itemid != "") $itemid = "&Itemid=" . $itemid;


	//function check_album_on($album_id){
		
		if(!$album_id) return true; // everybody can add an album if is a registered user
		
		$db =& JFactory::getDBO();
		$user =& JFactory::getUser();
                          $user_id = $user->id;
		$query = 'SELECT user_id, id, format_id, date FROM #__muscol_albums WHERE id = ' . $album_id ;
		$db->setQuery($query);
		$album_creator = $db->loadResult();
		
		if($album_id == $user_id) return true;
		echo id= '.$album_id';
		
	}