sql >> Databasteknik >  >> RDS >> Mysql

Hur man ekar ut tabellrader från db (php)

$sql = "SELECT * FROM MY_TABLE";
$result = mysqli_query($conn, $sql); // First parameter is just return of "mysqli_connect()" function
echo "<br>";
echo "<table border='1'>";
while ($row = mysqli_fetch_assoc($result)) { // Important line !!! Check summary get row on array ..
    echo "<tr>";
    foreach ($row as $field => $value) { // I you want you can right this line like this: foreach($row as $value) {
        echo "<td>" . $value . "</td>"; // I just did not use "htmlspecialchars()" function. 
    }
    echo "</tr>";
}
echo "</table>";


  1. Identifiera materialstycksstrukturen (BOM) i databaser

  2. Formatera SQLite-frågeresultat som kolumner med kolumnrubriker

  3. Ordna ett datum i SQL-servern

  4. Grundläggande tabelluttryck, del 8 – CTE:er, optimeringsöverväganden fortsatte