concatenation with multiple quotes while displaying html using PHP

105 Views Asked by At

Please assist in doing concatenation here

    echo"<form class='navbar-form navbar-left' role='search' method='POST' action='addr3.php'>
    <input type="hidden" name="id_delete" value="'.$id_r.'">
    <button type='submit' class='btn btn-primary'> I am Roaming </button>
    </form>";
3

There are 3 best solutions below

1
On BEST ANSWER

Make sure you dont use ' and " in the same way, this should work:

echo "<form class='navbar-form navbar-left' role='search' method='POST' action='addr3.php'>
<input type='hidden' name='id_delete' value='".$id_r."'>
<button type='submit' class='btn btn-primary'> I am Roaming </button>
</form>";
1
On

Some 's are not correctly Used. Change this -

value="'.$id_r.'" to value='" . $id_r . "'

type="hidden" to type='hidden'

name="id_delete" to name='id_delete'

The whole code will be -

echo "<form class='navbar-form navbar-left' role='search' method='POST' action='addr3.php'>
<input type='hidden' name='id_delete' value='" . $id_r . "'>
<button type='submit' class='btn btn-primary'> I am Roaming </button>
</form>";
0
On

Just reverse your quotes.

<?php
echo '<form class="navbar-form navbar-left" role="search" method="POST" action="addr3.php">
        <input type="hidden" name="id_delete" value="'.$id_r.'">
        <button type="submit" class="btn btn-primary"> I am Roaming </button>
    </form>';
?>