command0 Posted January 18, 2007 Share Posted January 18, 2007 Hi,I'm working on some PHP scripts, and am running in to some road blocks here ???What I'm trying to accomplish is I'm trying to show one thing, and then show another thing based on booleans and else if's. Here's an example:[code]<html> <head> <title>Test</title> </head> <body> <h1>Test</h1> <p>Paragraphs...bla bla bla....</p> <?php var boolean $tree = true; var boolean $twig = true; var string $appletree = "<ul> <li>I like Apples</li> <li>Apples are good</li> </ul>; var string $stick = "There is no tree here, just a stick!"; if ($tree) { echo ($appletree); } else { if ($twig) { echo ($stick); }; ?>[/code]Now, one thing I'm wondering is if I can use PHP variables to display HTML content or not, beyond just forms using post or get. I've tried going through the PHP Manual to see the use of variables being passed from HTML, and it didn't go much further than just passing from forms. I know this sort of thing can be accomplished in JavaScript, but I'm designing a site that some complete ignorant people will be using, so if it can be done without JavaScript, then more power to it. If it can be done, wouldn't it be something to the affect of "http://www.example.com/test.html?software=true" or http://www.example.com/test.html?twig=true" ?I'm not new to PHP, just trying to experiment, and see what the best way to go is. If someone can help me out, I'd appreciate it. Quote Link to comment Share on other sites More sharing options...
hvle Posted January 18, 2007 Share Posted January 18, 2007 I don't know if this is your problem, but you have a missing double quote and this may cause your program to run with error.behind the </ul>; you needed </ul>"; Quote Link to comment Share on other sites More sharing options...
taith Posted January 18, 2007 Share Posted January 18, 2007 ok... first problem... your treating php like its javascript... [s]var[/s][code]<html><head><title>Test</title></head><body><h1>Test</h1><p>Paragraphs...bla bla bla....</p><?php$tree = true;$twig = true;$appletree = "<ul><li>I like Apples</li><li>Apples are good</li></ul>";$stick = "There is no tree here, just a stick!";if($tree) echo $appletree;elseif($twig) echo$stick;?>[/code] 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.