Jump to content

[SOLVED] very quick and easy for php intermediate!


fri3ndly

Recommended Posts

Please can someone help me out here:

 

I am trying to make an IF statement that is something like this, you will get the general idea what I am trying to do but I really have not got my head round IF statements. Please help, thank you

 

 

 

<?php

 

if (page="?page=about.txt")

 

"<img src="images/aboutbar.jpg" width="800" height="141" />" ;

 

}

 

if (page="?page=services.txt")

 

"<img src="images/servicesbar.jpg" width="800" height="141" />" ;

 

}

 

else{

 

<img src="images/homebar.jpg" width="800" height="141" />

?>

Link to comment
Share on other sites


Ok, so this is my script now, but I keep receiving errors. Obviously I cannot echo an image to show up, so that is obviously wrong, anything else anyone notices? I think the script is not liking the html, do I need to end the php tags and restart them for each part of html?

 

	  if($_GET

==about.txt){
  
  echo "<img src="images/topleftbartest.jpg" width="800" height="141"/>";
  
  }elseif{
  echo "<img src="images/topleftbartest2.jpg" width="800" height="141"/>";
  
  }else{
  echo "<img src="images/topleftbartest2.jpg" width="800" height="141"/>";
              }
  ?>

Link to comment
Share on other sites


switch($_GET


){

case "about.txt":

  echo '<img src="images/topleftbartest.jpg" width="800" height="141"/>';

break;

case "":

  echo '<img src="images/topleftbartest2.jpg" width="800" height="141"/>';

break;

default:

  echo '<img src="images/topleftbartest2.jpg" width="800" height="141"/>';

break;

}

Link to comment
Share on other sites


thank you very much. That makes sense and the default image shows up, but the selected images do not.

 

	  <?php
  
switch($_GET

){
case "index2.php?page=about.txt":
  echo '<img src="images/topleftbar1.jpg" width="800" height="141"/>';
break;
case "index2.php?page=services.txt":
  echo '<img src="images/topleftbar2.jpg" width="800" height="141"/>';
break;
default:
  echo '<img src="images/topleftbar.jpg" width="800" height="141"/>';
break;
}
  ?>

 

I have tried changing the page names, but that is what the page name changes to in the top of the browser

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.