danjapro Posted April 8, 2011 Share Posted April 8, 2011 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...'; } } Quote Link to comment https://forums.phpfreaks.com/topic/233049-helpget-id-if-empy-or-null-to-follow-the-else-if/ Share on other sites More sharing options...
TapeGun007 Posted April 8, 2011 Share Posted April 8, 2011 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 == '') { Quote Link to comment https://forums.phpfreaks.com/topic/233049-helpget-id-if-empy-or-null-to-follow-the-else-if/#findComment-1198581 Share on other sites More sharing options...
danjapro Posted April 9, 2011 Author Share Posted April 9, 2011 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...'; } Quote Link to comment https://forums.phpfreaks.com/topic/233049-helpget-id-if-empy-or-null-to-follow-the-else-if/#findComment-1199155 Share on other sites More sharing options...
3raser Posted April 9, 2011 Share Posted April 9, 2011 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]; } Quote Link to comment https://forums.phpfreaks.com/topic/233049-helpget-id-if-empy-or-null-to-follow-the-else-if/#findComment-1199172 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.