LoginSignup
0
0

More than 1 year has passed since last update.

PHPでSQLのSELECTを使用する方法

Posted at

・PHPでSQLのSELECTを使用する方法
①query構文でSELECT
②whileとfetch_assocで各レコード毎に操作

画像の通り、dataというテーブルがあったとする
image.png

例)

<?php
$db = new mysqli("localhost:8889", "root", "root", "mydb");
$records = $db->query("select * from data");
if ($records) {
    while ($record = $records->fetch_assoc()) {
        echo $record['name'] . "<br>";
    }
} else {
    echo $db->error;
}
?>

補足画像)
image.png

結果)
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0