增刪改查 原始寫法

用框架寫久了 就會原始寫法忘了  今天特地備註一下mysql

$link = mysqli_connect('localhost','root','','school') or die;
$link->set_charset('utf8');
$abc = "select * from think_user";
$result = $link->query($abc);
$a = array();
while($row = $result->fetch_assoc()) {
    $a[] = $row;
}
echo '<pre>';
var_dump($a);

// 新增
$sql = "insert into think_user values('哈哈','尷尬')";

// 修改
$sql="update think_user set `name`='京客隆',`age`=20,`address`='長江索道' where id=20";

// 刪除
$sql="delete from think_user where id=20";
相關文章
相關標籤/搜索