Jump to content

Trying to hide content and need some help


command0

Recommended Posts

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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