Hey, on my site I use a variable to set a table header image..it works on everything except my news script.
echo "<td align='left' background='$cellheaderz' bgcolor='#FF0000'><div align='center'><b>News</b></font></div></td>";
$cellheaderz is the image I want..its in URL form, so it should work but for some reason the variable is cleared. Any ideas?
Could it be because I have functions in my news script?
Image using variable..problem
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
try this:
*edit* what do you mean the variable is cleared... to get the value of a variable in a URL you cannot simply echo the variable itself you have to use a $_GET for URL or $_POST from forms... or else you "think" the variable would of been cleared.
Code: Select all
<?
echo "<td align='left' background=".$_GET['cellheaderz']." bgcolor='#FF0000'><div align='center'><b>News</b></font></div></td>";
?this is also possible (saves up two characters! (w00t)
)
Code: Select all
<?php
echo "<td align='left' background={$_GET['cellheaderz']} bgcolor='#FF0000'><div align='center'><b>News</b></font></div></td>";
?>Well, that we can discuss, as you missed the issue about allways quoting values. Of course there are various of ways to to this, but...vigge89 wrote:this is also possible (saves up two characters! (w00t) :P)
Code: Select all
<?php
// last example
echo "<td align='left' background={$_GET['cellheaderz']} bgcolor='#FF0000'><div align='center'><b>News</b></font></div></td>";
// better
echo "<td align="left" background="{$_GET['cellheaderz']}" bgcolor="#FF0000"><div align="center"><b>News</b></font></div></td>";
?>