-5
Привет всем, У меня есть код, который отображает таблицу и строки, но все результаты отображаются в том же столбце, что и первый. Я хотел бы отображать результаты в разных столбцах. Большое спасибопоказать sql результаты в php с таблицами
echo "<table style='border: solid 1px black;'>";
echo "<tr><th>Id
</th><th>OFFER NAME
</th><th>OFFER ID
</th><th>TRAFICO
</th><th>FILTRADAS
</th><th>% FILTRADAS
</th><th>INICIADAS
</th><th>FINALIZADAS
</th><th>UNSUCCESSFUL INSTALLS
</th><th>% UNSUCCESSFUL INSTALLS
</th><th>SUCCESSFUL INSTALLS
</th><th>REVENUE
</th><th>BIDDING SCORE
</th></tr>";
$sql = "SELECT installs.advertiser_id FROM installs WHERE YEAR(installs.time_of_install) = YEAR(NOW()) AND MONTH(installs.time_of_install) = MONTH(NOW()) GROUP BY installs.advertiser_id LIMIT 10";
$sql = "SELECT softwares.software_name FROM softwares LIMIT 10";
class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}
function current() {
return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>";
}
function beginChildren() {
echo "<tr>";
}
function endChildren() {
echo "</tr>" . "\n";
}
}
try {
$conn = new PDO("mysql:host=$dbHost;dbname=$dbDB", $dbUser, $dbPass);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $conn->prepare("SELECT installs.advertiser_id FROM installs WHERE YEAR(installs.time_of_install) = YEAR(NOW()) AND MONTH(installs.time_of_install) = MONTH(NOW()) GROUP BY installs.advertiser_id LIMIT 10");
$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;
}
$stmt = $conn->prepare("SELECT softwares.software_name FROM softwares LIMIT 10");
$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;
echo "</table>";
die;