Page 1 of 1

Store HTML tags in PHP variables

Posted: Sat Jan 07, 2006 2:10 pm
by ffclan
How do i do that

Currently, I have this text feild.

Code: Select all

?>
<input name="textfield3" type="text" class="style18" id="textfield3" onfocus="this.blur()" value="
<?php
	  if ($image == "Yes")
	  $img_src = '<img src="http://www.fastfragclan.com/files/usr_ul/'.rawurlencode($name).'" />';
	  echo $img_src;
?>
	  " size="70" />
Mind you that $image is = to "Yes"

But the result: Inside the text field: <img src= and right next to it outside: " size="70" /> and it also displays the picture.

I want it to just display the HTML code for an image source in a textfield. I think the " inside the <img src="> tag is what's causing the problem.

Any help would be apreciated.

Thanks.

Posted: Sat Jan 07, 2006 2:17 pm
by ffclan
One other thing
what is the function for if statements for different values

eg: if ($car == "Toyota" or $car == "Nissan")

The point is the "OR" is it correct to put it like that?

Posted: Sat Jan 07, 2006 2:18 pm
by jayshields
If I'm reading your problem correctly, you are trying to show HTML image tags inside a text input field.

If this is the case, I would personally go about it by displaying the pointy brackets (< and >) using < and >.

So for example you wanted to show this

Code: Select all

<img src="myimage.jpg" height="300" width="300">
in a text input field, you could use this code

Code: Select all

<input type="text" name="somecode" size="100" value="<img src="myimage.jpg" height="300" width="300">">
Notice I've also used " instead of ", you could dodge that using single quotation marks, but it's bad practice. For a full list of HTML equivilents to symbols, check this page out.

Hope that helps :)

Edit: Just seen your other post. You could use either OR or ||, same goes with and, you could use AND or &&.

Posted: Sat Jan 07, 2006 2:25 pm
by ffclan
Not working. The text feild only shows <img src=

However, the " size="70" /> dont show no more.

Thanks anyway.

Posted: Sat Jan 07, 2006 4:30 pm
by Jenk

Code: Select all

?>
<input name="textfield3" type="text" class="style18" id="textfield3" onfocus="this.blur()" value="
<?php
      if ($image == "Yes")
      $img_src = htmlentities('<img src="http://www.fastfragclan.com/files/usr_ul/'.rawurlencode($name).'" />');
      echo $img_src;
?>
      " size="70" />

Posted: Sun Jan 08, 2006 4:35 am
by ffclan
Thanks, it worked great!