Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try{
- $pdo = NEW PDO('mysql:host=localhost;dbname=july2020project','root','password');
- }catch(PDOException $e){
- die($e->getMessage());
- }
- $result = $pdo->query("SELECT * FROM users");
- $all = $result->fetchAll();
- $col = $all[0];
- $columns = array();
- echo "<pre>";
- foreach($col AS $key=>$value){
- if(is_string($key)){
- $columns[] = $key;
- }
- }
- echo "<table border='1'>";
- foreach($columns AS $value){
- echo "<th>$value</th>";
- }
- for($x=0;$x<count($all);$x++){
- echo "<tr>";
- for($y=0;$y<count($columns);$y++){
- echo "<td>".$all[$x][$y]."</td>";
- }
- echo "</tr>";
- }
- ?>
Add Comment
Please, Sign In to add comment