PHP 5 provides sample code for managing any database tables in MySQL 5 (2). Read the sample code for managing any database tables in MySQL 5 (2). continue: click add to jump to add. php // add. phphtmlheadtitleAddanentrytothedatabase/titlemetahttp-equiv = "> <
Continued: Click add entry to jump to add. php.
// Add. php
Add an entry to the database
Add an entry
$ Database = "sunsite ";
$ Tablename = $ _ GET ['tablename'];
Mysql_connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "show columns from $ tablename ";
$ Result = mysql_db_query ($ database, $ query );
$ Column = 0;
If ($ result)
{
While ($ r = mysql_fetch_array ($ result ))
{
$ Colname [$ column] = $ r [0];
$ Column = $ column + 1;
}
Mysql_free_result ($ result );
}
$ Id = 0;
Do
{
$ Id ++;
$ Query = "select * from $ tablename where $ colname [0] = '$ ID '";
$ Result = mysql_db_query ($ database, $ query );
}
While (mysql_fetch_array ($ result ))
?>
"> Finish
IDs are automatically searched and generated, and they must be unique in the database. After you click add, the content will be written to the database. then, you will be asked to add the content until you finish adding the content and click finish to return to the previous layer. the database content after the added entry is displayed.
The addsoftware. php
// Addsoftware. php
$ Database = "sunsite ";
$ Tablename = $ _ POST ['tablename'];
Mysql_connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "show columns from $ tablename ";
$ Result = mysql_db_query ($ database, $ query );
$ Column = 0;
If ($ result)
{
While ($ r = mysql_fetch_array ($ result ))
{
$ Colname [$ column] = $ r [0];
$ Column = $ column + 1;
}
Mysql_free_result ($ result );
}
For ($ col = 0; $ col <$ column; $ col ++)
$ Para [$ col] =_ _ POST [$ colname [$ col];
If ($ _ POST ['name'])
{
Mysql_connect ("localhost", "root", "") or die ("Problem connecting to DataBase ");
$ Query = "insert into $ tablename values ('$ para [0]'";
For ($ col = 1; $ col <$ column; $ col ++)
$ Query = $ query. ", '". $ para [$ col]. "'";
$ Query = $ query .");";
$ Result = mysql_db_query ($ database, $ query );
Header ("Location: add. php? Tablename = $ tablename ");
}
Else
{
Echo "No name Entered. Please go back and reenter name ";
}
?>
To be continued.