php桌面中心(三) 修改数据库
php桌面中心(三) 修改数据库
发布时间:2016-12-29 来源:查字典编辑
摘要:下面这个程序在你输入id后就把那个id的数据列出来。然后你就可以修改后写入了.数据库的数据更新

下面这个程序在你输入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.php'method='post'>n

<table>n

<tr>n

<td>ID:<td><inputtype=textname='id'value='$id'></tr>n

<tr>n

<td>类形:<td><inputtype=textname='jpg'value='$jpg'></tr>n

<tr>n

<td>图片url地址:<td><inputtype=textname='url'size='100'value='$url'></tr>n

<tr>n

<td>说明:<td><inputtype=textname='mess'size='100'value='$mess'></tr>n

<tr>n

<td>来自:<td><inputtype=textname='fromx'size='100'value='$fromx'></tr>n

<tr>n

<td>图片url地址:<td><inputtype=textname='url1'size='100'value='$url1'></tr>n

<tr>n

<td>说明:<td><inputtype=textname='mess1'size='100'value='$mess1'></tr>n

<tr>n

<td>来自:<td><inputtype=textname='fromx1'size='100'value='$fromx1'></tr>n

<tr>n

<td>图片url地址:<td><inputtype=textname='url2'size='100'value='$url2'></tr>n

<tr>n

<td>说明:<td><inputtype=textname='mess2'size='100'value='$mess2'></tr>n

<tr>n

<td>来自:<td><inputtype=textname='fromx2'size='100'value='$fromx2'></tr>n

<tr>n

<td>图片url地址:<td><inputtype=textname='url3'size='100'value='$url3'></tr>n

<tr>n

<td>说明:<td><inputtype=textname='mess3'size='100'value='$mess3'></tr>n

<tr>n

<td>来自:<td><inputtype=textname='fromx3'size='100'value='$fromx3'></tr>n

</table>n

<inputtype=submitvalue='更新'>n

</form>n";

}

else

{?>

<h3>请输放需要更改的id:</h3>

<center><formaction='ww.php'method='post'>

<br>

动漫桌布

<inputtype="radio"name="jpg"value="jpg"checked>

平分秋色水彩画

<inputtype="radio"name="jpg"value="jpg1">

明星写真

<inputtype="radio"name="jpg"value="jpg2">

广告创意

<inputtype="radio"name="jpg"value="jpg3">

其它类

<inputtype="radio"name="jpg"value="jpg4">

<br>

<inputtype=textname='id'>

<inputtype=submitvalue='查询'>

</form></center>

<?}?>

</body>

</html>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类