$pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password"); $stmt = $pdo->query("SELECT * FROM mytable"); $result = $stmt->fetch(PDO::FETCH_ASSOC); echo $result['column_name'];
$conn = mysqli_connect("localhost", "username", "password", "mydatabase"); $result = mysqli_query($conn, "SELECT * FROM mytable"); $row = mysqli_fetch_assoc($result); echo $row['column_name'];This code connects to the "mydatabase" database using mysqli and selects all rows from the "mytable" table. The mysqli_fetch_assoc() function retrieves the first row of data from the result set and returns it as an associative array. The "column_name" value is then printed.