makamo66 Posted December 28, 2019 Share Posted December 28, 2019 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. Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/ Share on other sites More sharing options...
Barand Posted December 28, 2019 Share Posted December 28, 2019 Sounds like you're not doing it correctly. 1 Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572928 Share on other sites More sharing options...
NotSunfighter Posted December 28, 2019 Share Posted December 28, 2019 You need to post your code Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572930 Share on other sites More sharing options...
benanamen Posted December 28, 2019 Share Posted December 28, 2019 Thanks for letting us know. Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572933 Share on other sites More sharing options...
mac_gyver Posted December 28, 2019 Share Posted December 28, 2019 i'm going with the answer 42. Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572934 Share on other sites More sharing options...
ginerjm Posted December 28, 2019 Share Posted December 28, 2019 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? Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572937 Share on other sites More sharing options...
makamo66 Posted December 28, 2019 Author Share Posted December 28, 2019 <table border='1'><tr><th>Remove </th><th width='100'>Your Product </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) </td>"; echo "<td> \$" . $price . "</td><td> \$" . $number . "</td></tr>"; echo "</form>"; echo "</table>"; Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572939 Share on other sites More sharing options...
Barand Posted December 28, 2019 Share Posted December 28, 2019 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.) Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572940 Share on other sites More sharing options...
makamo66 Posted December 28, 2019 Author Share Posted December 28, 2019 None of the variables echo out. Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572944 Share on other sites More sharing options...
ginerjm Posted December 28, 2019 Share Posted December 28, 2019 Have the variables been assigned any values yet? Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572945 Share on other sites More sharing options...
ginerjm Posted December 28, 2019 Share Posted December 28, 2019 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 </th> <th width='100'>Your Product </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) </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! Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572947 Share on other sites More sharing options...
Barand Posted December 28, 2019 Share Posted December 28, 2019 @ginerjm those currency symbols need escaping otherwise they are interpreted as variable variables ($$price, $$number) <td>\${$price}</td> <td>\${$number}</td> Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572948 Share on other sites More sharing options...
ginerjm Posted December 28, 2019 Share Posted December 28, 2019 I thought the braces might address that. Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572950 Share on other sites More sharing options...
Barand Posted December 28, 2019 Share Posted December 28, 2019 (edited) Alas, {}s are part of the variable variable syntax edit: $a = 'foo'; $$a = 'bar'; echo $$a; //--> bar echo ${$a}; //--> bar echo $foo; //--> bar Edited December 28, 2019 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1572951 Share on other sites More sharing options...
makamo66 Posted December 31, 2019 Author Share Posted December 31, 2019 ThanX ginerjm. Your code worked perfectly (except that the dollar signs needed to be escaped) Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1573016 Share on other sites More sharing options...
ginerjm Posted January 1, 2020 Share Posted January 1, 2020 So - did you learn how to output html and php vars a little better? Quote Link to comment https://forums.phpfreaks.com/topic/309760-echoing-out-variable-in-a-table-cell-doesnt-work/#findComment-1573034 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.