...

View Full Version : <?PHP echo etc displaying but don't want it!



Ipssissimus
01-30-2010, 05:20 PM
Hi

I want to be able to pick up the variable from the switch/case statements and use it within the echo text (html) of the case.

When I view the source code of the page that that holds the code below, the $id is replaced with the variable (great) but it also shows the rest of the text <?php echo....... The variable that is picked up is also the name of the .jpg image and I would like the script to populate this automatically for all the instances where this occurs. Is it possible or am I hoping for too much?


<img class='prodimage' src='../images/<?php echo \"$id\" ; ?>.jpg'>


Many thanks

Andrew

bdl
01-30-2010, 05:55 PM
So... are we viewing the HTML markup here or the PHP source? If / when you post PHP code, please use the PHP tags.

sitNsmile
01-31-2010, 01:28 AM
<img class='prodimage' src='../images/<?php echo $id; ?>.jpg'>

Make sure this is in a file for .php (html will not run php codes properly)
In a normal .php page this will work just perfectly.

thekooliest
01-31-2010, 02:53 AM
Like sitNsmile showed, you do not need quotations around a variable so instead of what you had:
<?php echo \"$id\"; ?>

You would use:
<?php echo $id; ?>

-Sam

met
01-31-2010, 11:22 AM
Hi

I want to be able to pick up the variable from the switch/case statements and use it within the echo text (html) of the case.

When I view the source code of the page that that holds the code below, the $id is replaced with the variable (great) but it also shows the rest of the text <?php echo....... The variable that is picked up is also the name of the .jpg image and I would like the script to populate this automatically for all the instances where this occurs. Is it possible or am I hoping for too much?


<img class='prodimage' src='../images/<?php echo \"$id\" ; ?>.jpg'>


Many thanks

Andrew


If "<?php <value of $id; ?>" is being output then there is something weird going on.

<?php just tells the parser when there is PHP to process ~ it should never be returned to the browser unless explicitly said so.

Normally if tags are output, PHP isn't enabled, but you said the variable gets processed implying PHP is.

Post this case statement as well.

as for replacing any instance of the variable...thats what variables do. Replace any instance with the value. So i think there is some confusion here.

post the whole code



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum