桌面中心(三)修改数据库
桌面中心(三)修改数据库,桌面中心(三)修改数据库
桌面中心(三)修改数据库
作者:elong
下面这个程序在你输入id后就把那个id的数据列出来。然后你就可以修改后写入了.
<html
<body
<h1数据库的数据更新</h1
<?
if(isset($id))
{
if(!mysql_connect("localhost","用户名","密码"))
{echo"无法联接数据库";
exit();
}
if(isset($url))
{
$query="update $jpg set id=’$id’,url=’$url’,mess=’$mess’,
fromx=’$fromx’,url1=’$url1’,mess1=’$mess1’,fromx1=’$fromx1’,url2=’$url2’,
mess2=’$mess2’,fromx2=’$fromx2’,url3=’$url3’,mess3=’$mess3’,fromx3=’$fromx3’
where id=’$id’" ;
$result=mysql_db_query("elong",$query); //执行写入
if (!$result)
{echo "发生错误!";
exit();
}
echo "$id 已经更新!
";
echo "<tablen
<trn
<tdID<td$id</trn
<trn
<tdurl地址<td$url</trn
<trn
<td小图<td$mess</trn
<trn
<td说明<td$fromx</trn
<trn
<tdurl地址1<td$url1</trn
<trn
<td小图1<td$mess1</trn
<trn
<td说明1<td$fromx1</trn
<trn
<tdurl地址2<td$url2</trn
<trn
<td小图2<td$mess2</trn
<trn
<td说明2<td$fromx2</trn
<trn
<tdurl地址3<td$url3</trn
<trn
<td小图3<td$mess3</trn
<trn
<td说明3<td$fromx3</trn
</tablen";
echo "<a href=’set.htm’回到首页</a";
exit();
}
$query="SELECT id,url,mess,fromx,url1,mess1,fromx1,url2,mess2,fromx2,url3,mess3,fromx3 from $jpg
where id=’$id’" ;
$result=mysql_db_query("elong",$query);
if (!$result)
{echo "发生错误!";
exit();
}
$r=mysql_fetch_array($result);
$id = $r["id"];
$url = $r["url"];
$mess = $r["mess"];
$fromx = $r["fromx"];
$url1 = $r["url1"];
$mess1 = $r["mess1"];
$fromx1 = $r["fromx1"];
$url2 = $r["url2"];
$mess2 = $r["mess2"];
$fromx2 = $r["fromx2"];
$url3 = $r["url3"];
$mess3 = $r["mess3"];
$fromx3 = $r["fromx3"];
echo"
<form action=’ww.php’ method=’post’n
<tablen
<trn
<tdID:<td <input type=text name=’id’ value=’$id’</trn
<trn
<td类形:<td <input type=text name=’jpg’ value=’$jpg’</trn
<trn
<td图片url地址:<td <input type=text name=’url’ size=’100’ value=’$url’</trn
<trn
<td说明:<td <input type=text name=’mess’ size=’100’ value=’$mess’</trn
<trn
<td来自:<td <input type=text name=’fromx’ size=’100’ value=’$fromx’</trn
<trn
<td图片url地址:<td <input type=text name=’url1’ size=’100’ value=’$url1’</trn
<trn
<td说明:<td <input type=text name=’mess1’ size=’100’ value=’$mess1’</trn
<trn
<td来自:<td <input type=text name=’fromx1’ size=’100’ value=’$fromx1’</trn
<trn
<td图片url地址:<td <input type=text name=’url2’ size=’100’ value=’$url2’</trn
<trn
<td说明:<td <input type=text name=’mess2’ size=’100’ value=’$mess2’</trn
<trn
<td来自:<td <input type=text name=’fromx2’ size=’100’ value=’$fromx2’</trn
<trn
<td>