Help, get userid with else _GET

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, get userid with else _GET

Post 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;
Post Reply