You can use this following functions:
First one is mysql_fetch_array() which fetch a result row as an associative array, a numeric array, or both.
Second mysqli_fetch_assoc() which fetch a result row as an associative array
Example code on how to delete records using PHP in MYSQL database server.
<?php
// variables
$user = "localhost"; $username = "root";
$password = "password";
// connect to database
$db = new mysqli($user,$username,$password); $db->select_db('your_databse');
if (mysqli_connect_errno()) {
die( "Connection failed..." );
}
// select records
$query = ("SELECT id, username, firstname, lastname FROM tbl_users"); if ($rs = mysqli_query($db, $query)) {
while ($row = mysqli_fetch_assoc($rs)) {
$id = $row["id"];
$username = $row["username"];
$firstname = $row["firstname"];
$lastname = $row["lastname "];
}
mysqli_free_result($rs);
}
//outputs
echo "ID: ".$id."<br>";
echo "USERNAME: ".$username."<br>";
echo "FIRSTNAME: ".$firstname."<br>";
echo "PASSWORD: ".$lastname ."<br>";
?>
1 comments:
typo error
mysqli_free_result($rsDateTime);
myslqi_free_result($rs);
Post a Comment