I have a PHP script that creates tables with 3 rows in the admin's database(users).
$sql1="CREATE TABLE '".$username."' (id int(5) AUTO_INCREMENT, ip VARCHAR(255), password VARCHAR(255), PRIMARY KEY (id))";
So I want to have all the tables (it's rows and data) in the users database displayed on admin's dashboard like this:
<h3>Table_Name</h3>
<tr>
<th>Row1</th><th>Row2</th><th>Row3</th>
</tr>
<tr>
<td>All Data On Row1</td><td>All Data On Row2</td><td>All Data On Row3</td>
</tr>
Please someone should help me with a tested php mysql query on this issue. I sincerely don't have an idea on how to make this work. My xamp isn't helping matters because it can't seem to connect with the database, so i find it difficult testing my code; so help me with a tested and working code.
show TABLES;
DESCRIBE your_table_name;
This is how you display the data display from database into the HTML tables
create a database connection
$dbCon= mysqli_connect("localhost","root","root","test");
if(mysqli_connect_errno()){
echo "Failed to connect: ". mysqli_connect_errno();
}
?>
Then in your php file where you want to show the data in the form of tables
<table>
<thead>
<tr>
<th>No.</th>
<th>IP.</th>
<th>Password</th>
</tr>
</thead>
<tbody>
<?php
require("connection.php");
$query="SELECT * FROM your_table_name ";
$result = mysqli_query($dbCon, $query)or die(mysqli_error($dbCon));
while($row=mysqli_fetch_array($result,MYSQLI_ASSOC))
{
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['ip']; ?></td>
<td><?php echo $row['password']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
If you have more data to show just add the column name.