add background image

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • learnPHP
    New Member
    • Mar 2008
    • 20

    add background image

    Hi,

    I have 2 background images.
    Ineed to add the first image if the value of variable test is 1 otherwise i need to add the second background image.

    I have written the following code:
    Code:
    <?PHP
    			   if ($test ==1)
    			   echo "<td width='50%' valign='top'  STYLE='background-image: url('img/table_faoback.jpg');'>";
    			   else
    			   echo "<td width='50%' valign='top'  STYLE='background-image: url('img/table_back.jpg');'>";
    			  
    			   ?>
    However it does not display any image. Please let me know how to do this.

    Thanks.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by learnPHP
    Hi,

    I have 2 background images.
    Ineed to add the first image if the value of variable test is 1 otherwise i need to add the second background image.

    I have written the following code:
    Code:
    <?PHP
    			   if ($test ==1)
    			   echo "<td width='50%' valign='top'  STYLE='background-image: url('img/table_faoback.jpg');'>";
    			   else
    			   echo "<td width='50%' valign='top'  STYLE='background-image: url('img/table_back.jpg');'>";
    			  
    			   ?>
    However it does not display any image. Please let me know how to do this.

    Thanks.
    Check your source code: is there <td width='... printed out?

    If so: this is not a php problem: it is echoing through the conditional statement and your problem lies in the html!

    regards

    Comment

    • nomad
      Recognized Expert Contributor
      • Mar 2007
      • 664

      #3
      Originally posted by learnPHP
      Hi,

      I have 2 background images.
      Ineed to add the first image if the value of variable test is 1 otherwise i need to add the second background image.

      I have written the following code:
      Code:
      <?PHP
      			 if ($test ==1)
      			 echo "<td width='50%' valign='top' STYLE='background-image: url('img/table_faoback.jpg');'>";
      			 else
      			 echo "<td width='50%' valign='top' STYLE='background-image: url('img/table_back.jpg');'>";
       
      			 ?>
      However it does not display any image. Please let me know how to do this.

      Thanks.

      You might try this...
      background-image: url(img/table_back.jpg) ;

      Also you need to look at your html coding as well as markusn00b suggested. Something is not right with the ;

      nomad

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by nomad
        You might try this...
        background-image: url(img/table_back.jpg) ;

        Also you need to look at your html coding as well as markusn00b suggested. Something is not right with the ;

        nomad
        It may be the single quotes within single quotes that are causing the problem.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          You should at least escape the single quotes within the single quotes in this statement[php]STYLE='backgrou nd-image: url('img/table_faoback.j pg');'>";[/php]Ronald

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Markus you beat me again!

            Ronald

            Comment

            • Markus
              Recognized Expert Expert
              • Jun 2007
              • 6092

              #7
              Originally posted by ronverdonk
              Markus you beat me again!

              Ronald
              That's just how i get down

              8]

              You've been slacking ron!
              Where you been?

              Comment

              • ronverdonk
                Recognized Expert Specialist
                • Jul 2006
                • 4259

                #8
                Originally posted by markusn00b
                That's just how i get down

                8]

                You've been slacking ron!
                Where you been?
                Very busy with making some websites.

                Ronald

                Comment

                Working...