Continued: click "add an entry" to jump to "add. php" (as the mainstream development language)
// Add. php (as the mainstream development language)
<Html>
<Head> <title> Add an entry to the database </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
</Head>
<Body bgcolor = # ffffff>
<H2> Add an entry <? 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 );
}
$ Id = 0;
Do
{
$ Id ++;
$ Query = "select * from $ tablename where $ colname [0] = $ id ";
$ Result = MySQL (the best combination with PHP) _ db_query ($ database, $ query );
}
While (MySQL (best combination with PHP) _ fetch_array ($ result ))
?>
<Form method = "post" action = "addsoftware. php (as the mainstream development language)">
<Table width = 90% align = center>
<Tr> <td> <? Php (as the mainstream development language) echo "$ colname [0]";?> : </Td> <? Php (as the mainstream development language) echo "$ id";?> </Td> </tr>
<?
For ($ col = 1; $ col <$ column; $ col ++)
Echo "<tr> <td> $ colname [$ col]: </td> <input type = text name = $ colname [$ col] size = "100%"> </td> </tr> ";
?>
<Input type = hidden name = "<? Php (as the mainstream development language) echo "$ colname [0]";?> "Value =" <? Php (as the mainstream development language) echo "$ id";?> ">
<Input type = hidden name = tablename value = "<? Php (as the mainstream development language) echo "$ tablename";?> ">
<Tr> <td> </td> <input type = submit value = "Add"> </td> </tr>
</Table>
</Form>
<A href = "tables. php (as the mainstream development language )? Tablename = <? Echo "$ tablename"?> "> Finish </a>
</Body>
</Html> IDs are automatically searched and generated, and 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.
Below is the addsoftware. php (as the mainstream development language) for database operations during the addition process)
// Addsoftware. php (as the mainstream development language)
<? Php (as the mainstream development language)
$ Database = "sunsite ";
$ Tablename = $ _ POST [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 );
}
For ($ col = 0; $ col <$ column; $ col ++)
$ Para [$ col] =_ _ POST [$ colname [$ col];
If ($ _ POST [name])
{
MySQL (best combination with PHP) _ 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 (the best combination with PHP) _ db_query ($ database, $ query );
Header ("Location: add. php (as the mainstream development language )? Tablename = $ tablename ");
}
Else
{
Echo "No name Entered. Please go back and reenter name ";
}
?>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
To be continued.