Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $driver = 'mysql';
- $database = "dbname=CODINGGROUND";
- $dsn = "$driver:host=localhost;$database";
- $username = 'root';
- $password = 'root';
- try {
- $conn = new PDO($dsn, $username, $password);
- echo "Database CODINGGROUND Connected\n";
- }catch(PDOException $e){
- echo $e->getMessage();
- }
- $sql = 'SELECT * FROM users';
- $stmt = $conn->prepare($sql);
- $stmt->execute();
- while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
- foreach($row as $value)
- {
- echo sprintf("%s, ", $value);
- }
- echo "\n";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement