-4

How can i display form data in echo php ?

My code is:

<?php
    echo "<td align='center' style='vertical-align:middle;'> Bust:
    <?php
        echo $_POST["bust"];
    ?>
    <br> Waist:
    <?php
        echo $_POST["waist"];
    ?>
    <br> </td>";
?> 

But this doesn't work, please guide me with correct steps.

Blaatpraat
  • 2,829
  • 11
  • 23
Ravindra
  • 11
  • 8
  • 1
    Move your code to your question, there is an edit button. Also please include the full output of your table, and post the code for your form itself – cwurtz Apr 29 '15 at 14:03
  • You're already inside PHP and echo, so why the added code of the same inside it? – Funk Forty Niner Apr 29 '15 at 14:13
  • Sorry sir @CJWurtz i am new to Stackoverflow, The error come for above code, syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\gown-gowns\web\checkout.php on line 156 – Ravindra Apr 29 '15 at 14:14
  • you've an answer below if you haven't seen it yet, you can accept it to close the question. – Funk Forty Niner Apr 29 '15 at 14:40

1 Answers1

2

There are a lot of problems with your code.

  1. You're using " in $_POST["bust"] but you opened echo with " as well, causing a conflict.
  2. You're using <?php instead an echo... which is already PHP. There's no need to do this.

It is best to isolate variable printing from your code. Use string concatenation with . as such:

echo "<td align='center' style='vertical-align:middle;'> Bust: ".$_POST["bust"]."<br> Waist: ".$_POST["waist"]."<br> </td>";
Muhammad Abdul-Rahim
  • 1,980
  • 19
  • 31