So I have a mysql db, and I've connected to it, but I'm not sure how to print out the table/row contents in php. I have sort of figured out how to print out the results of queries and I've gotten "SHOW TABLES;" to print but I want the row contents to be printed too. Anyone know how? Here's what I have now for printing out queries:
while($row = mysqli_fetch_assoc($i)){
foreach($row as $cname => $cvalue){
echo $cname. ":". $cvalue";
}
}
You can use information_schema to get all columns for each table of the current database :
select table_name, column_name
from information_schema.columns
where table_schema = database()
so you want a table that shows your requested data. You could make a HTML table by using the <table> </table>
. then you can just echo out the row and fill in the fields. you must make a loop though to go through all the data stored in your $row
echo <tr> <td> the value you want </td> </tr>;
the <tr> </tr>
are the rows and the <td> </td>
are the fields. ofcourse you can add as many fields and rows you want. So the end product would look something like this.
`<table>
<?php
foreach(your condition)
{
echo
<tr>
<td> value you want in this field of the row </td>
<td> second value you </td>
</tr>;
}
?>
</table>`
let me know if this is the solution you were searching for and if not give me some more info maybe i can come up with another solution:). Btw this is my first post/aswer so if i f***** something up with the layout teach me senpai:D.