Code:
<?php
$conn = mysql_connect('dbserver', 'dbusername', 'dbpassword');
mysql_select_db('databasename');
$tablename = 'mytable';
if(isset($_GET['delete']))
if(!is_numeric($_GET['delete'])) die();
else mysql_query('delete from `' . $tablename . '` where id=' . $_GET['delete'] . ';');
$rs = mysql_query('select * from `' . $tablename . '`;');
$row = mysql_fetch_array($rs);
$cols = array();
foreach($row as $k => $v)
array_push($cols, $k);
array_push($cols, 'del');
echo('<table><tr>');
for($i = 0; $i < count($cols); ++$i)
echo('<th>' . $cols[$i] . '</th>');
echo('</tr>');
do {
$row['del'] = '<form action="?delete=' . $row['id'] . '" method="get"><input type="submit" value="Delete"></form>';
echo('<tr>');
for($i = 0; $i < count($cols); ++$i) {
?>
<td><?php echo($row[$i]); ?></td>
<?php
}
echo('</tr>');
} while($row = mysql_fetch_array($rs));
echo('</table>');
?>
Untested.
Bookmarks