Home >Backend Development >PHP Tutorial >PHP5对Mysql5的任意数据库表的管理代码示例(二)

PHP5对Mysql5的任意数据库表的管理代码示例(二)

WBOY
WBOYOriginal
2016-06-01 14:26:48853browse

续:点击添加一个条目就会跳转到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))
?>




for ($col=1;$colecho "";
?>
" value="">
">

:
$colname[$col]:


">Finish

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn