2Answer
Use This Code to Create table 2 to 20
<html>
<head>
<title>Create a table 2 to 20 using for loop in php</title>
</head>
<body>
<?php
echo "<table border ='1'>";
for ($row=1; $row <= 10; $row++)
{
echo "<tr> \n";
for ($col=1; $col <= 20; $col++)
{
$p = $col * $row;
echo "<td>$p</td> \n";
}
echo "</tr>";
}
echo "</table>";
?>
</body>
</html>
- answered 7 years ago
- Community wiki
<?php
* connect to the db */
$connection = mysql_connect('localhost','username','password');
mysql_select_db('my_db',$connection);
/* show tables */
$result = mysql_query('SHOW TABLES',$connection) or die('cannot show tables');
while($tableName = mysql_fetch_row($result)) {
$table = $tableName[0];
echo '<h3>',$table,'</h3>';
$result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('cannot show columns from '.$table);
if(mysql_num_rows($result2)) {
echo '<table cellpadding="0" cellspacing="0" class="db-table">';
echo '<tr><th>Field</th><th>Type</th><th>Null</th><th>Key</th><th>Default<th>Extra</th></tr>';
while($row2 = mysql_fetch_row($result2)) {
echo '<tr>';
foreach($row2 as $key=>$value) {
echo '<td>',$value,'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
}
?>
- answered 7 years ago
- Sunny Solu
Your Answer