關於課程
<?php
$pdo=new PDO(‘mysql:host=localhost;dbname=shop;charset=utf8’,
‘root’, ‘12345678’);
foreach ($pdo->query(‘select * from product’) as $row) {
echo “<p>$row[id]:$row[name]:$row[price]</p>”;
}
?>
或
<?php
$pdo=new PDO(‘mysql:host=localhost;dbname=shop;charset=utf8’,
‘root’, ‘12345678’);
foreach ($pdo->query(‘select * from product’) as $row) {
echo ‘<p>’;
echo $row[‘id’], ‘:’;
echo $row[‘name’], ‘:’;
echo $row[‘price’];
echo ‘</p>’;
}
?>