Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: Jostein
- * Date: 20.03.2016
- * Time: 22:30
- **/
- $servername = "mysql.stud.ntnu.no";
- $username = "andrkje_jobbquiz";
- $password = "K5lt2qpp";
- $dbname = "jobbquiz";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $stmt = $conn->prepare("SELECT *FROM postal_code");
- $stmt->execute();
- // set the resulting array to associative
- $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
- foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
- echo $v;
- }
- }
- catch(PDOException $e) {
- echo "Error: " . $e->getMessage();
- }
- $conn = null;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement