Jump to content

Help,get $id if empy or null to follow the else if


danjapro

Recommended Posts

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..

 

 

Code:

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

}

Just curious, but are the $id values set to nothing or NULL?

 

} else if($id == ' ') {

 

In any case, you have a space in there where $id == ' ', so it's checking to see if the $id is equal to the equivalent of a space.  Try removing that space.

 

} else if($id == '') {

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 . '&tmpl=component&print=1';
      	 	$url=JURI::root().'index.php?'.$component.'&userid='.$_GET['userid'].'&id='.$id.'&tmpl=component&print=1';
   		for($i=1;$i<count($type);$i++){
    		$url.='&'.$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&view=album&id=27&tmpl=component&print=1';
   		for($i=1;$i<count($type);$i++){
    		$url.='&'.$type[$i].'='.$layout[$i];
  }
    } else {
	echo 'User Album Loading...';
	}

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 . '&tmpl=component&print=1';
      	 	$url=JURI::root().'index.php?'.$component.'&userid='.$_GET['userid'].'&id='.$id.'&tmpl=component&print=1';
   		for($i=1;$i<count($type);$i++){
    		$url.='&'.$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&view=album&id=27&tmpl=component&print=1';
   		for($i=1;$i<count($type);$i++){
    		$url.='&'.$type[$i].'='.$layout[$i];
  }
    } else {
	echo 'User Album Loading...';
	}

 

You have an if & else statement with a else statement closing it. Why?

 

Try this:

 

<?php

if ($id) 
{
	if (!$user->get('id') == 0 || !$userid || $userid != $user->get('id')){	

     		//$url = JURI::root() . 'index.php?' . $component . '&id=' . $id . '&tmpl=component&print=1';
      	 	$url=JURI::root().'index.php?'.$component.'&userid='.$_GET['userid'].'&id='.$id.'&tmpl=component&print=1';

   		for($i=1;$i<count($type);$i++){
    		$url.='&'.$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*/

}
elseif(!$file) 
{
    $url=JURI::root().'index.php?option=com_muscol&view=album&id=27&tmpl=component&print=1';
for($i=1;$i<count($type);$i++){
$url.='&'.$type[$i].'='.$layout[$i];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.