Continued: If you click Delete to delete an entry, it will jump to del. php (as the mainstream development language)
// Del. php (as the mainstream development language)
<Html>
<Head> <title> Deleting an entry from the database </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
</Head>
<Body bgcolor = # ffffff>
<H2> Delete an entry <?
$ Database = "sunsite ";
$ Tablename = $ _ REQUEST [tablename];
Echo "MySQL (best combination with PHP) _ connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "show columns from $ tablename ";
$ Result = MySQL (the best combination with PHP) _ db_query ($ database, $ query );
$ Column = 0;
If ($ result)
{
Echo "Found these entries in the database: <br> <p> </p> ";
Echo "<table width = 90% align = center border = 1> <tr> ";
While ($ r = MySQL (the best combination with PHP) _ fetch_array ($ result ))
{
Echo "<td align = center bgcolor = #00 FFFF> $ r [0] </td> ";
$ Colname [$ column] = $ r [0];
$ Column = $ column + 1;
}
Echo "</tr> ";
MySQL (the best combination with PHP) _ free_result ($ result );
$ Query = "select * from $ tablename ";
$ Result = MySQL (the best combination with PHP) _ db_query ($ database, $ query );
If ($ result)
While ($ r = MySQL (the best combination with PHP) _ fetch_array ($ result ))
{
Echo "<tr> ";
Echo "<td> <a href =" dele. php (as the mainstream development language )? $ Colname [0] = $ r [0] & tablename = $ tablename "> $ r [0] </td> ";
For ($ col = 1; $ col <$ column; $ col ++) echo "<td> $ r [$ col] </td> ";
Echo "</tr> ";
}
Echo "</table> ";
}
Else echo "No data .";
MySQL (the best combination with PHP) _ free_result ($ result );
?>
<A href = "tables. php (as the mainstream development language )? Tablename = <? Echo "$ tablename"?> "> Finish </a>
</Body>
</Html>
Then write the data to the database.
// Dele. php (as the mainstream development language)
<? Php (as the mainstream development language)
$ Database = "sunsite ";
$ Tablename = $ _ GET [tablename];
MySQL (best combination with PHP) _ connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "show columns from $ tablename ";
$ Result = MySQL (the best combination with PHP) _ db_query ($ database, $ query );
$ Column = 0;
If ($ result)
{
While ($ r = MySQL (the best combination with PHP) _ fetch_array ($ result ))
{
$ Colname [$ column] = $ r [0];
$ Column = $ column + 1;
}
MySQL (the best combination with PHP) _ free_result ($ result );
}
$ Para = $ _ GET [$ colname [0];
MySQL (best combination with PHP) _ connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "delete from $ tablename where $ colname [0] = $ para ;";
$ Result = MySQL (the best combination with PHP) _ db_query ($ database, $ query );
Header ("Location: edit. php (as the mainstream development language )? Tablename = $ tablename ");
?>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
The above is all the code.
Put them all under the same directory.
Note: reminder! When copying the above Code, be sure to remove the tab before each line of code in the editor. Otherwise, php (as the mainstream development language) 5 cannot be compiled.
In addition, $ database in each file is currently sunsite, and $ table is software, which can be modified as needed.
Comments are welcome.