i got alot of tables in my database, and i have specific buttons for each of the table, so when i click on one of the buttons it should display the table rows and columns in a div but it does not display properly for eg
Note: every table has different number columns and different number rows
This is what it looks like
This is what i want, for each of the table
$query = "SELECT * FROM ghousn.$table";
$result = mysqli_query($connection, $query);
echo" <table >";
while($row = mysqli_fetch_assoc($result)){
foreach($row as $key => $val){
echo "<tr>";
echo"<th>$key</th>
</tr>
<tr>
<td>$val</td>
</tr>";
}
}
echo "</table>";
}
$query = "SELECT * FROM FROM ghousn.$table";
$result = mysqli_query($connection,$query);
echo" <table border='1' >";
while($row = mysqli_fetch_assoc($result)){
echo "<tr>";
foreach($row as $key => $val){
echo"<th>$key</th> ";
}
echo "</tr>";
echo"<tr>";
foreach($row as $key => $val){
echo "<td>$val</td>";
}
echo "</tr>";
}
echo "</table>";
try this
$query = "SELECT * FROM ghousn.$table";
$result = mysqli_query($connection, $query);
echo" <table >";
while($row = mysqli_fetch_assoc($result)){
echo "<tr>";
foreach($row as $key => $val){
echo"<th>$key</th>
</tr>
<tr>
<td>$val</td>";
}
echo "</tr>"
}
echo "</table>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.