Thanks again for your help!
I will explain my intensions more thoroughly. I have a website with e.g. a guestbook, guestbook entries will be stored in the guestbook table on the mysql database. This all works properly. Using PhpMyAdmin I would be able to delete a row from this table, but I want to be able to do this on the webpage. So I built a password protected area (admin.php) where all tables of the database are shown like this:
0 Guestbook
1 Some table
2 Some other table
Choose table: [ 'id' ]
'Submit'
Using the id of the table (0-1-2 in this case) you can select that table and that table will be built by change.php. Using the checkboxes selected rows must be deleted.
So everything works properly, except the deleting part..
here are all the files I use for this (upgraded a bit after your improvements),
<!-- verbinding.php -->
<?php
$dbhost = "***";
$db = "***";
$dbname = "***";
$username = "***";
$dbww = "***";
?>
<!-- admin.html -->
<HTML>
<HEAD>
<TITLE>admin.html</TITLE>
</HEAD>
<BODY>
Welkom op de admin.
A.u.b. inloggen:
<form method=post action=admin.php>
Username: <input type="text" name="name">
Wachtwoord: <input type"password" name="password">
<input type="submit" name="submit">
</form>
</BODY>
</HTML>
<!-- admin.php -->
<HTML>
<HEAD>
<TITLE>Admin.php</TITLE>
</HEAD>
<?php
include("verbinding.php");
if ($_POST['submit']) {
$name = $_POST['name'];
$password = $_POST['password'];
if (($name == $username) && ($password == $dbww)) {
mysql_connect("$dbhost","$username","$dbww");
echo "kies een tabel.";
show(); ?>
<BODY>
<form action=change.php method=post>
<input type="text" name="id">
<input type="submit" name="submit">
</form>
<?php
} else { ?>
Foute username en wachtwoord combinatie ingevuld, <a href="admin.html">probeer opnieuw</a> // wrong password/user combination
<?php }
}
function show()
{
$tabellen = mysql_list_tables("$dbname");
$i=0;
while ($i < mysql_num_rows($tabellen)){
$t_name[$i] = mysql_tablename ($tabellen, $i);
echo $i, $t_name[$i]. "";
$i++;
}
}?>
</BODY>
</HTML>
<!-- change.php -->
<?php
if ($_POST['submit']) {
$id = $_POST['id'];
$i = 0;
include("verbinding.php");
mysql_connect("$dbhost", "$username", "$dbww")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");
$tabellen = mysql_list_tables("$dbname") or die("cannot list tables");
while ($i < mysql_num_rows($tabellen)) {
$t_name[$i] = mysql_tablename ($tabellen, $i);
if ($id == $i) {
$tbl_name = $t_name[$i];
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$fields_num = mysql_num_fields($result);
?>
<HTML>
<HEAD>
<TITLE>Change.php</TITLE>
</HEAD>
<BODY>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
<tr>
<td bgcolor="#FFFFFF"> </td>
<td colspan="4" bgcolor="#FFFFFF"><strong>Table: <?php echo $t_name[$i]; ?></strong> </td>
</tr>
<tr>
<?php
echo "<td bgcolor='#FFFFFF'>#</td>";
for($k=0; $k<$fields_num; $k++) {
$field = mysql_fetch_field($result);
echo "<td bgcolor='#FFFFFF'>{$field->name}</td>";
}
while($row = mysql_fetch_row($result)) {
echo "<tr>";
?>
<td align="center" bgcolor="#FFFFFF"><form method="post" action="<?php echo $PHP_SELF;?>"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['id']; ?>"></td>
<?php
foreach($row as $cell)
echo "<td bgcolor='#FFFFFF'>$cell</td>";
echo "</tr>\n";
}
?>
</tr>
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td>
<td colspan="2" align="center" bgcolor="#FFFFFF"><input name="back" type="submit" id="back" value="Back"></td></form>
</tr>
<?php
if($_POST['delete']=="Delete") {
$checkbox = $_POST['checkbox[]'];
for($i=0;$i<$count;$i++) {
$del_id = $checkbox[$i];
$result = mysql_query("DELETE FROM $tbl_name WHERE id='".mysql_real_escape_string($del_id)."'") or die("Query Error!");
}
if($result){
//Here a code to reload change.php
}
}
if($_POST['back']=="Back"){
//Here a code to reload admin.php
}
}
$i++;
}
mysql_close();
}
?>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>