note 107163 deleted from pdo.query by tularis
| From: | tularis@php.net | Date: | Thu, 12 Jan 2012 11:25:15 +0000 |
| Subject: | note 107163 deleted from pdo.query by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185602@lists.php.net to get a copy of this message | ||
Note Submitter: Erik
Reason: bad code
----
Nice way of geting all inforamtion without knowing the column names
<?php
function make_query($queryString, $db, $user, $password){
$dbh = new PDO($db, "$user", "$password");
$result = $dbh->query($queryString);
$row = $result->fetchAll(PDO::FETCH_ASSOC);
if ($row){
foreach ($row as $column => $value){
foreach ($value as $ItemKeyCell => $ItemContentValue){
echo "$ItemKeyCell :<b> $ItemContentValue</b><br>";
}
echo "<hr>";
}
} else { echo "db realtion has no data inside";}
$dbh = null;
}
$db = "mysql:host=$server;dbname=$database";
$query = "SELECT * FROM User";
make_query($query, $db, "$user", "$password");
?>