Jump to content
makamo66

Echoing out variable in a table cell doesn't work

Recommended Posts

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. 
 

Share this post


Link to post
Share on other sites
1 hour ago, makamo66 said:

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. 
 

What exactly are you telling us?  An echo is an echo.  What is the problem here?   The real problem is that you aren't giving us anything to look at in order to help you.  Does that make sense to you?

Share this post


Link to post
Share on other sites

<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>";
 

Share this post


Link to post
Share on other sites

Which variable doesn't echo out. They all do for me once I put something in them.

(BTW, You should've learnt to use code tags by now.)

Share this post


Link to post
Share on other sites

Try running this code.  I've added an echo at the start and end to give you at least something to 'see' if it is actually running.  If it is not, then you need to find the errors.  AND get your ini file updated to allow you to turn on error checking when you need it.

<?php
echo "Script is beginning<br>";
$code=<<<heredocs
<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>
<form method='post' name='yourForm'>
<tr><td></td>
<td><img src="$thumbnail"/></td>
<td>$cart_product_quantity</td>
<td>{$product}(s)&nbsp;&nbsp;</td>
<td>${$price}</td>
<td>${$number}</td>
</tr>
</form>
</table>
heredocs;
echo $code;
echo "<br>Script finished";

When you test this and have problems, show us the code as you ran it and be sure to show us how those vars are being set!

 

Share this post


Link to post
Share on other sites

@ginerjm those currency symbols need escaping otherwise they are interpreted as variable variables ($$price, $$number)

<td>\${$price}</td>
<td>\${$number}</td>

 

Share this post


Link to post
Share on other sites

So - did you learn how to output html and php vars a little better?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.