Even layout is broken by the number of characters of the name extracted in the part of "echo"", $row ['name'],"";I would like to align just this part, but what kind of treatment should I do?

Thanks for your professor.

<!-Read header->
<? php session_start ();?>
<? php require "header.html";?>

<? php

echo "<table>";
echo "<th>My Number</th><th>User Name</th><th>Price</th>";
$pdo = new PDO ('mysql: host = localhost;dbname = shop7;charset = utf8', 'staff', 'password');
if (isset ($_ REQUEST ["keyword"])) {
    $sql = $pdo->prepare ("select * from product where name like?");
    $sql->execute (["%". $_ REQUEST ["keyword"]. "%"]);
} else {
    $sql = $pdo->prepare ("select * from product");
    $sql->execute ([]);
foreach ($sql->fetchAll () as $row) {
    $id = $row ['id'];
        echo '<table>';
        echo "<tbody>";
        echo "<tr>";
        echo '<th scope = "row">aaa</th>';
        echo "<td>$id</td>";
        echo "<td>", $row ['name'], "</td>";// part of the problem
        echo "<td>bbb</td>";
        echo "<td>bbb</td>";
        echo "</tr>";
        echo "</tbody>";
        echo "</table>";

.table {
  width: 100%;
  margin-bottom: 1rem;
  color: # 212529;

I want to apply it to the top line like the second gray space from the bottom, but I can't confirm the regularity.
It is in a stopped state.

* If i increase the number of characters in the part that contains the product name after "1", the number of blank lines, which are gray parts, increases accordingly.

Supplemental information (FW/tool version etc.)

OS: mac

I am using bootstrap4 and reading it.

  • Answer # 1

    Make a mock with static html instead of making it suddenly with php, then adjust the shape with php.
    If you can't create static html, you can't get the expected layout from php.

  • Answer # 2

    prepare ("select * from product where name like?");
        $sql->execute (["%". $_ REQUEST ["keyword"]. "%"]);
    } else {
        $sql = $pdo->prepare ("select * from product");
        $sql->execute ([]);
    $rows = $sql->fetchAll ();
    My numberusernamePrice

Related articles