Page 1 of 1

Help, get userid with else _GET

Posted: Tue Mar 22, 2011 5:03 pm
by danjapro
Ok, hot to incorporate that with a running and else statement:
Where if $user->id is not the user in url, then use the $userid from GET. in url.

Code: Select all

// Return with empty data
		if ($user->id == null || empty($user->id)) {
		//return false;
		}
		// Query the database for the user
		$sql = 'SELECT * FROM jos_muscol_albums WHERE user_id = ' . $user->id;
} else if isset($_GET['userid']) ? (int)$_GET['userid'] : JRequest::getVar('userid');  
		// Query the database for the user
		$sql = 'SELECT * FROM jos_muscol_albums WHERE user_id = ' . $_GET['userid'];
}		
		$result = mysql_query($sql) or die('Error, No Album Search failed');
		//$result = mysql_query($sql) or die('Error, No Album Search failed<br />' . mysql_error());   
		
		if (mysql_num_rows($result) > 0) {
		list($id, $year, $name) = mysql_fetch_array($result);
		
		// Display the results
		//echo $id . '<br />' . $user->id . '<br />' . $year;
		//echo $name;