Simpe PHP Code Question
January 4, 2006 12:13 PM
Subscribe
How do I arrange this PHP code so that it does what it is supposed to do?
First of all, here is the code:
http://rafb.net/paste/results/QUVmtU10.html
Specifically, I'm concerned with lines 6-48, the IF/ELSE stuff. I don't know PHP but I can usually figure code like this with a little trial and error. Thus far I've failed with this piece though. At first it was just a bunch of IF statements with an ELSE at the end. Then I tried using a flag so that anytime the IF failed, the ELSE would be triggered. That didn't work either. Basically, I want the IF/ELSE statement to apply to each of the "IFs." Right now, it logically works with the "photos" line since that's the only one where the if is followed directly by the ELSE (I thought the flags would fix this but it didn't). I tried also putting the ELSE statement after each of the IFs but that seems to break things. How do I arrange the code so that it works with "bookmarks," "links" and "clippings"? Presently, when I click the photos link, it only shows photos. But for the other three, it'll show both the IF and the ELSE. I hope my question makes sense. Thanks for any help you provide. If needed, I can post a link to the blog where the code is presently in use (but not correctly implemented obviously).
Feel free to use
Paste (); if you want to alter the code.
posted by panoptican to computers & internet (35 comments total)
How about the following:
if(!empty($bookmarks)) include "bookmarks.php";
if(!empty($clippings)) include "clippings.php";
if(!empty($links)) include "links.php";
if(!empty($photos)) include "photos.php";
$flag = false;
if( !empty($bookmarks) || !empty($clippings) || !empty($links) ||
!empty($photos)) $flag == true;
...
posted by thanotopsis at 12:26 PM on January 4, 2006