Get the IF $id to work if there is no$id

This piece of code works perfect if the user has a $id listed in DB and is returned from the SQL Query that collects the need values, which first follws this piece of code.

However, if the user does not have a $id in that table, it should do the else if, but it goes straight to the last else.

What should the else if($id == ’ ') or else if(empty($id == ’ '))??
PLEASE HELP…


	if ($id) {
		if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){	
     		//$url = JURI::root() . 'index.php?' . $component . '&id=' . $id . '&amp;tmpl=component&amp;print=1';
      	 	$url=JURI::root().'index.php?'.$component.'&amp;id='.$id.'&amp;tmpl=component&amp;print=1';
	   		for($i=1;$i<count($type);$i++){
	    		$url.='&amp;'.$type[$i].'='.$layout[$i];
	  		}
		}
	} else if($id == ' ') {
      	 	$url=JURI::root().'index.php?option=com_muscol&amp;view=album&amp;id=27&amp;tmpl=component&amp;print=1';
	   		for($i=1;$i<count($type);$i++){
	    		$url.='&amp;'.$type[$i].'='.$layout[$i];
	  }
    } else {
		echo 'User Album Loading...';
		} 
		
}

where you declared $id?
And where you assigned $id value?

Do you mean here, with my SQL query???


		if (isset($_GET['userid'])) {    
		$userid = $GET['userid'];}

		// Query the database for the user
		$sql = 'SELECT album_id AS id, disc_num, name, artist_id AS real_artist_id, filename, extension AS file, `added`, `genre_id`, `hits` FROM jos_muscol_songs WHERE user_id = ' .$_GET['userid'];
					
		$result = mysql_query($sql) or die('Error, No Album Search failed');
		   if (mysql_num_rows($result) &gt; 0) {
		list($id, $disc_num, $name, $real_artist_id, $filename, $file, $added, $genre_id, $hits) = mysql_fetch_array($result);

you already used this;
if (isset($_GET[‘userid’]))
like this you can use for your problem;

if (isset($_GET[‘id’]))
or
if (isset($_POST[‘id’]))

} else if($id == ’ ') {
make to

} else if(!ISSET($id) || $id == '' ) {

Based on the way you use list, if there is no result it will not populate the variable. Also you are looking to see if $id is equal to a string containing only a space, as opposed to being empty.

Tired all these methods you guys have provided.
Nothing works, still does not take the user to the else if url setting.

I have it like this now and nothing works. no errors though.


	if ($id) {
		if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')){	
     		//$url = JURI::root() . 'index.php?' . $component . '&id=' . $id . '&amp;tmpl=component&amp;print=1';
      	 	$url=JURI::root().'index.php?'.$component.'&amp;userid='.$_GET['userid'].'&amp;id='.$id.'&amp;tmpl=component&amp;print=1';
	   		for($i=1;$i<count($type);$i++){
	    		$url.='&amp;'.$type[$i].'='.$layout[$i];
	  		}
		}
	/*MG made this change here to get the user to got ot set Default Account if they have not one yet. Account Album ID = 27. CaribbeanHeat.tv Main Account.Yah. Mg all the way baby. 042776*/
			
	} else if($file == '' ) {
      	 	$url=JURI::root().'index.php?option=com_muscol&amp;view=album&amp;id=27&amp;tmpl=component&amp;print=1';
	   		for($i=1;$i<count($type);$i++){
	    		$url.='&amp;'.$type[$i].'='.$layout[$i];
	  }
    } else {
		echo 'User Album Loading...';
		}