forum share
   textsms      forum    

PHP MySQLi Procedural and Object-Oriented Interface

INDEX \ Articole/intrebari \ PHP MySQLi Procedural and Object-Oriented Interface

PHP MySQLi Procedural and Object-Oriented Interface

text_format+  text_format-


Object Oriented Interface

//connect to database
$mysqli = new mysqli("localhost", "username", "password", "database");

//check for errors
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: " . $mysqli->connect_error;
}

//write query
$res = $mysqli->query("SELECT  * from tablename");

//fetch query
$row = $res->fetch_assoc();

//display results
echo $row['table_id'];


Object Oriented Interface

//Connect to the database
$con=mysqli_connect("localhost", username", "password", "database") or die(mysqli_connect_error());

//Write query
$query="SELECT * from tablename";

//Fetch results
$result=mysqli_query($con, $query);

//Display results
while($row=mysqli_fetch_array($result)) {
//use row to fetch the element of each column
}
//close connection
mysqli_close($con);






update Ultima actualizare: 22/05/2021
done Informatiile cuprinse in aceasta sectiune sunt verificate si actualizate periodic.

list Articole recente
arrow_back Inapoi


© 2024 EVIDWEB. Toate drepturile rezervate. Design: EVIDWEB

share   forum   textsms