标签:soc mys select last result HERE while 语句 sso
https://www.runoob.com/php/php-mysql-create.html
以下两种方式:
Mysqli extension
PDO
$query = "select first_name,last_name" from users where user_id=‘$id‘";
$result = mysqli_query($conn,$query);
while($row = mysqli_fetch_assoc($result)){
$first = $row["first_name"];
$last = $row["last_name"];
$html .= "
ID: {$id}";
First name: {$first}
Surname: {$last}
$data = $db->prepare( ‘SELECT first_name, last_name FROM users WHERE user_id = (:id) LIMIT 1;‘ );
$data->bindParam( ‘:id‘, $id, PDO::PARAM_INT );
$data->execute();
$row = $data->fetch();
当然还有对于整数的查询和模糊查询,加上对应的闭合即可。
标签:soc mys select last result HERE while 语句 sso
原文地址:https://www.cnblogs.com/lyxsalyd/p/12053710.html