Help, query user info, for echo or hidden fields

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danjapro
Forum Commoner
Posts: 72
Joined: Mon Sep 27, 2004 10:56 am

Help, query user info, for echo or hidden fields

Post by danjapro »

I am ok with codeing but NOT half-as good as some of your GUYS here.
I'm trying to write a simple sql query based on returning certain values from a table for that user.

I would like to just beable to include this as a page user.info.php and render it on any page as include to return need values .

See My CODE. PLESE HELP ME.

Code: Select all

<?php 

		// Set cookie
		$userid = JRequest::getVar('userid');		
		
		$data       = new stdClass();
		$model      =& $this->getModel('profile');
		$my         = CFactory::getUser();
		
		// Test if userid is 0, check if the user is viewing its own profile.
		$db =& JFactory::getDBO();
		$user =& JFactory::getUser();
        $userId = $user->id;

		// Return with empty data
		if($userId == null || $userId == '')
		{
			//return false;
		}

		$user		=& JFactory::getUser($userId);
		
		if($user->id == null){
			//return false;
		}
		
		$id = & JFactory::getUser($userId);
		$query = 'SELECT user_id, id, format_id, year, name FROM #__muscol_albums WHERE user_id = ' . $id;
		//$query = 'SELECT user_id FROM #__muscol_albums WHERE id = ' . $album_id ;
		$result = mysql_query($query) or die('Error, No Album Search failed');
		list($name, $user_id, $id, $year) = mysql_fetch_array($result);
	
	 
		echo $id;
		echo $user_id;
		echo $year;
			
			 
	 		
    // preform id return check and redirecto to correct url
    if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){
	 $url=JURI::root().'index.php?'.$component.'&id='.$id.'&tmpl=component&print=1';
	} else {
    $url=JURI::root().'index.php?option=com_community&view=profile&id=1&tmpl=component&print=1'; //redirect      is a function 
	 
	}

?>
Post Reply