Answers for "connecting to database and performing sql queries"

PHP
0

connecting to database and performing sql queries

<?php 
//Connecting to the database
$conn =  mysqli_connect('localhost', 'root', '', 'peroHub');

if(!$conn){
    echo "Error in connection: " . mysqli_connect_error();
}

$sql = 'SELECT title, ingredients, id FROM pizzas';

$result = mysqli_query($conn, $sql);


$pizza = mysqli_fetch_all($result, MYSQLI_ASSOC);

//free result from memory
mysqli_free_result($result);

//close connection
mysqli_close($conn);

// print_r($pizza);


?>
Posted by: Guest on September-06-2021

Browse Popular Code Answers by Language