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

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

WBOY
WBOYOriginal
2016-05-22 18:41:13942browse

续:点击编辑一个条目会跳转至edit.php
//edit.php

Editing an entry from the database



Edit an entry


$database = "sunsite";
$tablename = $_REQUEST['tablename'];
echo "

Data from $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)
{
echo "Found these entries in the database:

";
echo "";
while ($r = mysql_fetch_array($result))
{
echo "";
$colname[$column] = $r[0];
$column = $column + 1;
}
echo "";
mysql_free_result($result);

$query = "select * from $tablename";
$result = mysql_db_query($database, $query);
if ($result)
while ($r = mysql_fetch_array($result))
{
echo "

";
echo "";
for($col=1;$col$r[$col]";
echo "";
}
echo "
$r[0]
$r[0]
";
}
else echo "No data.";
mysql_free_result($result);
?>
">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