DelightedD0D DelightedD0D - 3 months ago 8
PHP Question

echo multiple variables with a space between each into echo'd table cell

<?php if(isset($_SESSION['guest2First']))
echo '<tr><td>';
echo '<input type="text" name="guest2Ticket" id="guest2Ticket" onblur="isTicketNumber(this)" size ="22"/>';
echo '</td><td>';
echo $first["guest2First"] , ' ', $middle["guest2Middle"] , ' ',$last["guest2Last"];
echo '</td></tr>'?>


I have a form that uses $_SESSION variables to fill in some of the content using the code above.

What I need to do is


  1. check if a variable is set

  2. if it is echo out a new table row containing two cells

  3. in the first cell echo out an input box

  4. in the second cell echo out 3 variables with a space between each



Everything seems to work fine except number 4. Nothing is is echo'd into the second cell.

Im sure that

echo $first["guest2First"] , ' ', $middle["guest2Middle"] , ' ',$last["guest2Last"];


is the problem. How can I fix this syntax to achieve my desired result?

Answer

I think you mixed the var names and mean $_SESSION, instead of $first, $middle, $last

<?php if(isset($_SESSION['guest2First']))
echo '<tr><td>';
echo '<input type="text" name="guest2Ticket" id="guest2Ticket" onblur="isTicketNumber(this)"  size ="22"/>';
echo '</td><td>';
echo $_SESSION["guest2First"] , ' ', $_SESSION["guest2Middle"] , ' ',$_SESSION["guest2Last"];
echo '</td></tr>'?>