PHP

PHP : MYSQL 객체지향

제주도 조랑말 2023. 4. 10. 15:23
728x90

<?php
$mysqli
= new mysqli("localhost", "my_user", "my_password", "world");

/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}

$query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 150,5";

if (
$stmt = $mysqli->prepare($query)) {

/* execute statement */
$stmt->execute();

/* bind result variables */
$stmt->bind_result($name, $code);

/* fetch values */
while ($stmt->fetch()) {
printf ("%s (%s)\n", $name, $code);
}

/* close statement */
$stmt->close();
}

/* close connection */
$mysqli->close();
?>

728x90

'PHP' 카테고리의 다른 글

PHP : Header location을 이용한 페이지 이동  (0) 2023.04.11
PHP : 글 깨짐 방지  (0) 2023.04.10
PHP : Content Type text/html Charset=utf-8  (0) 2023.04.04
PHP : HTML<select>, <option> selected로 받아오기  (0) 2023.03.28
PHP: substr  (0) 2023.03.28