When I echo out my variable in the php file it works fine but when I put the variable in a table cell it doesn't echo out.

    You should provide som code.
    So we see what you mean.

      <table border='1'><tr><th>Remove&nbsp;&nbsp;&nbsp;</th><th width='100'>Your Product&nbsp;&nbsp;</th><th>Quantity</th><th>Description</th><th>Price per item</th><th>Sub Total</th></tr>
      
      <?php
      
      echo "<form method='post' name='yourForm'>";
      
      echo "<tr><td></td>";
      
      echo "<td><img src=" . $thumbnail .   "/></td>";
      
      echo "<td>" . $cart_product_quantity . "</td>";
      
      echo "<td> " . $product . "(s)&nbsp;&nbsp;</td>";
      
      echo "<td> \$" . $price . "</td><td> \$" . $number .  "</td></tr>";
      
      echo "</form>";
      
      echo "</table>";
      `
      ````

        The only I can see is that <img src should be quoted.

        Like src="thumbnail" or src='thumbnail'
        Otherwise your code is good what I can see.

          Well, there's also some faulty HTML (a <form> tag inside a <table> tag, for example—there aren't any form fields anyway so the <form> isn't doing anything; that will cause pain later especially if this is going to be in a loop to support multiple products). But that's not going to actually stop the value displaying, unless there's something else in the stylesheet to hide it.

          Have you looked at the page source in the browser to see if the value really is there? When you say you echo it out "in the php file it works fine" how is that different from echoing it out in a table cell (since presumably you're doing that in a php file as well).

            There's a delete button in the form that I removed in order to make the code easier to read.

              The value isn't there in the page source.

                If nothing is being output for a specific variable, maybe throw in a bit of debug code to test if it's empty:

                if(!isset($varName) or trim($varName) === '') {
                  die('ERROR: $varName is empty.');
                }
                

                If that error pops up, then check (case-sensitive) variable spelling, look at the logic where it should get set, etc.

                  7 days later

                  Also, check the source in an HTML editor that can do highlighting in case you're having a quoting issue that's hiding part of your HTML.

                    Write a Reply...