<?php

$str = "HELLO WORLD";
print $str.nl2br("\n");
echo $str. nl2br("\n");


$link = mysqli_connect('localhost', 'root', 'autoset','test');
//if connection is not successful you will see text error
if (!$link) {
    die('Could not connect: ' . mysqli_error());
}
//if connection is successfuly you will see message bellow
echo nl2br("Connected successfully\n");


$result = mysqli_query($link, "SELECT * FROM shop");
if(!$result){
    die('Invalid query:'. mysqli_erro());
}

$result2 = mysqli_query($link, "SELECT * FROM shop");
if(!$result){
    die('Invalid query:'. mysqli_erro());
}

while ($row = mysqli_fetch_array($result)){
    printf(nl2br("name: %s   nametext: %s \n"), $row['name'], $row['nametext']);
}

while ($row2 = mysqli_fetch_assoc($result2)) {
    printf(nl2br("name: %s   nametext: %s \n"), $row2['name'], $row2['nametext']);
}

mysqli_free_result($result);
mysqli_close($link);
?>


'개발 > DataBase,PHP' 카테고리의 다른 글

mysql C# connector  (0) 2019.03.02
mariaDB SQL  (0) 2018.05.26

+ Recent posts