Forum Moderators: coopster

Message Too Old, No Replies

wrapping html in an if statement

         

anzagi

2:46 pm on Sep 18, 2008 (gmt 0)

10+ Year Member



Hi everyone,

I am quite new to php, only done a form here and there!

I am trying to have an if statement so that if a particular parameter is passed, the page shows one thing, if its not, it shows nothing.

here is my code

<td>
<?php echo $_GET['subject']; if ( $subject == "#*$!" ){?>
<img src="image.jpg" />
<?php } ?>
</td>

ok, so subject, is being passed through the URL into this page, so if 'subject' = #*$! for example, then I want image.jpg to show if it equals yyy then I want nothing to show.

does that make sense? I just can't get it to work....

many thanks in advance

jatar_k

2:50 pm on Sep 18, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



$_GET['subject'] and $subject are not the same thing

you have 2 choices

change to this
if ( $_GET['subject'] == "aaa" ){

or assign the value of $_GET['subject'] to $subject

<?php
echo $_GET['subject'];
$subject = $_GET['subject'];
if ( $subject == "aaa" ){
?>

I would also suggest separating lines of code onto separate actual lines, believe me, it will make more sense

anzagi

3:21 pm on Sep 18, 2008 (gmt 0)

10+ Year Member



That works a treat, thanks for your hlpe.

for info I used:

if ( $_GET['subject'] == "aaa" ){