I try to get the values for columns in a table. First i want to fetch the tables. then i did like:
$sql = $dbh->query("DESCRIBE `players` ;");
foreach ($sql->fetchAll(PDO::FETCH_NUM) as $k) {
echo 'Table:' . $k[0]. '<input type="text" values=""><br> ' ;
}
So what is best way now to get value for each table in same foreach?
SOLUTION HOW I DID:
function getColumnValue($column,$name) {
global $dbh;
$sqll = ("SELECT `$column` FROM `players` WHERE `name`='$name' ");
$sthh = $dbh->prepare($sqll);
$sthh->execute();
return $sthh->fetch(PDO::FETCH_ASSOC);
}
foreach ($sql->fetchAll(PDO::FETCH_NUM) as $k) {
$test = getColumnValue($k[0],'Test');
echo 'Table: '.$k[0] .' <input type="text" value="'.$test[$k[0]].'" style="color:#000;"> <br> ';
}