Home > Software engineering >  How to show two echoes in one line
How to show two echoes in one line

Time:01-20

How to make them appear in one line. I saw some other post which says to use echo -n but if I use it, it would give me an error

I want the "Name" and textbox to have some spacing in between, so I can align the other textboxes below.

echo "<p style='width:50%'>Name:</p>";
echo "<input type='text' name='name' value='$row[Name]'/>";

enter image description here

CodePudding user response:

This is rather a question about HTML, not PHP.

echo "<p style='width:50%'>Name: <input type='text' name='name' value='{$row['Name']}'/></p>";

CodePudding user response:

Here's a short snippet that uses <input> and <label>. You can see they are on the same line.

<div >
    <label for="input1">Name</label>
    <input type="text" name="name" id="input1">
</div>

If you need to align textboxes it gets more complicated, and you should use something more modern like grid layout:

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout

div.container {
    display:grid;
    grid-template-columns: max-content max-content;
    grid-gap:5px;
}
div.container label       { text-align:right; }
<div >

    <label>Label 1</label>
    <input type="text" id='input1'/>

    <label>Label 2</label>
    <input type="text" />

</div>

  •  Tags:  
  • Related