themeatpuppet Posted July 28, 2007 Share Posted July 28, 2007 I'm pulling out links from a database, some of them are images, some are movies, some are URLs and some are just download files. I need a way to differentiate each of the to be printed in the anchor tag this is what I'm doing: for($j=0;$j<count($links);$j++) { // explode on '.' to separate string $link_path = explode('.',$links['link_path']); // get last element for extension $link_path=$link_path[count($link_path)-1]; if($link_path=='jpg'|| $link_path=='gif'|| $link_path=='png'|| $link_path=='JPG'|| $link_path=='jpeg'|| $link_path=='JPEG'|| $link_path=='GIF'|| $link_path=='PNG'|| $link_path=='swf'|| $link_path=='SWF') { $link_image = getimagesize($folder.'/'.links['link_path']); $link_location = $folder.'/'; $link_target = "\" onclick=\"popUp(this.href,'console',$link_image[1],$link_image[0]);return false;\" target=\"newWin\">"; } elseif($link_path=='cfm'||$link_path='htm'||$link_path='html') { $link_location = $folder.'/'; $link_target = '">'; } else { $link_location=''; $link_target = '">'; } $links_div .='<li><a href="'.$link_location.$links['link_path'].$link_target.$links['link_name'].'</a>'; if(($i!=count($links))||$i==0) { $links_div .= " | </li>"; } else { $links_div .= "</li>"; } } Well the idea makes sense to me, but for some reason i don't understand, the loop is skipping the last else statement and those links that should be processed as such end up as the second elseif. It's like a riddle ??? ??? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 28, 2007 Share Posted July 28, 2007 Simple typo. Change this line: } elseif($link_path=='cfm'||$link_path='htm'||$link_path='html') { to } elseif($link_path=='cfm'||$link_path=='htm'||$link_path=='html') { You were using a single equals sign, which is the assignment operator. It will always evaluate to true, so that elseif would never fail. Quote Link to comment Share on other sites More sharing options...
themeatpuppet Posted July 28, 2007 Author Share Posted July 28, 2007 blast! i tought i've corrected that before, i cant believe it was actually that, i guess with so many of them i got kungfused thanks! Quote Link to comment 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.