Ich brauche Schleife td innerhalb während holen.Looping <td> hängt von rowCount innerhalb ab, während
Die td-Schleife hängt von der rowCount-Variablen ab der ersten Abfrage ab.
<?php include'../db/dbConnect.php';
$_GET['tb'];
$t=$_GET['tb'];
$q=$con->prepare("desc $t");
$q->execute();
$h=$q->rowCount(); ?>
<table>
<tr>
<?php while($r=$q->fetch(PDO::FETCH_NUM)){ ?>
<th><?php echo $r[0];?></th>
<?php } ?>
</tr>
<?php
$q=$con->prepare("select*from $t");
$q->execute();
while($r=$q->fetch(PDO::FETCH_NUM)){
$d=$r[0];
?>
<tr>
<td><?php echo $d;?></td>
</tr>
<?php } ?>
</table>
Above Code geben Ergebnis:
col1 col2 col3
12
13
14
Aber ich brauche das Ergebnis mit:
col1 col2 col3
12 vala x
13 valb y
14 valc z
muss es geben td auf rowCount Variable abhängt.
Ich habe versucht, vorher td zu loopen, indem ich while, aber das bin ich nicht die Logik bekommen.
Ich schätze einige Logik oder Rat der Frage.