php桌面中心(三) 修改数据库
2018-09-07 14:09
下面这个程序在你输入id后就把那个id的数据列出来。然后你就可以修改后写入了.
<html>
<body>
<h1>数据库的数据更新</h1>
<?
if(isset($id))
{
if(!mysql_connect(localhost,用户名,密码))
{echo无法联接数据库;
exit();
}
if(isset($url))
{
$query=update$jpgsetid=$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
whereid=$id;
$result=mysql_db_query(elong,$query);//执行写入
if(!$result)
{echo发生错误!;
exit();
}
echo$id已经更新!<br><br>;
echo<table>n
<tr>n
<td>ID<td>$id</tr>n
<tr>n
<td>url地址<td>$url</tr>n
<tr>n
<td>小图<td>$mess</tr>n
<tr>n
<td>说明<td>$fromx</tr>n
<tr>n
<td>url地址1<td>$url1</tr>n
<tr>n
<td>小图1<td>$mess1</tr>n
<tr>n
<td>说明1<td>$fromx1</tr>n
<tr>n
<td>url地址2<td>$url2</tr>n
<tr>n
<td>小图2<td>$mess2</tr>n
<tr>n
<td>说明2<td>$fromx2</tr>n
<tr>n
<td>url地址3<td>$url3</tr>n
<tr>n
<td>小图3<td>$mess3</tr>n
<tr>n
<td>说明3<td>$fromx3</tr>n
</table>n;
echo<ahref=set.htm>回到首页</a>;
exit();
}
$query=SELECTid,url,mess,fromx,url1,mess1,fromx1,url2,mess2,fromx2,url3,mess3,fromx3from$jpg
whereid=$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
<formaction=ww.phpmethod=post>n
<table>n
<tr>n
<td>ID:<td><inputtype=textname=idvalue=$id></tr>n
<tr>n
<td>类形:<td><inputtype=textname=jpgvalue=$jpg></tr>n
<tr>n
<td>图片url地址:<td><inputtype=textname=urlsize=100value=$url></tr>n
<tr>n
<td>说明:<td><inputtype=textname=messsize=100value=$mess></tr>n
<tr>n
<td>来自:<td><inputtype=textname=fromxsize=100value=$fromx></tr>n
<tr>n
<td>图片url地址:<td><inputtype=textname=url1size=100value=$url1></tr>n
<tr>n
<td>说明:<td><inputtype=textname=mess1size=100value=$mess1></tr>n
<tr>n
<td>来自:<td><inputtype=textname=fromx1size=100value=$fromx1></tr>n
<tr>n
<td>图片url地址:<td><inputtype=textname=url2size=100value=$url2></tr>n
<tr>n
<td>说明:<td><inputtype=textname=mess2size=100value=$mess2></tr>n
<tr>n
<td>来自:<td><inputtype=textname=fromx2size=100value=$fromx2></tr>n
<tr>n
<td>图片url地址:<td><inputtype=textname=url3size=100value=$url3></tr>n
<tr>n
<td>说明:<td><inputtype=textname=mess3size=100value=$mess3></tr>n
<tr>n
<td>来自:<td><inputtype=textname=fromx3size=100value=$fromx3></tr>n
</table>n
<inputtype=submitvalue=更新>n
</form>n;
}
else
{?>
<h3>请输放需要更改的id:</h3>
<center><formaction=ww.phpmethod=post>
<br>
动漫桌布
<inputtype=radioname=jpgvalue=jpgchecked>
平分秋色水彩画
<inputtype=radioname=jpgvalue=jpg1>
明星写真
<inputtype=radioname=jpgvalue=jpg2>
广告创意
<inputtype=radioname=jpgvalue=jpg3>
其它类
<inputtype=radioname=jpgvalue=jpg4>
<br>
<inputtype=textname=id>
<inputtype=submitvalue=查询>
</form></center>
<?}?>
</body>
</html>