您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
桌面中心(三) 修改数据库
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:36:37
下面这个程序在你输入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 已经更新!<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 "<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
<table>n
<tr>n
<td>ID:<td> <input type=text name='id' value='$id'></tr>n
<tr>n
<td>类形:<td> <input type=text name='jpg' value='$jpg'></tr>n
<tr>n
<td>图片url地址:<td> <input type=text name='url' size='100' value='$url'></tr>n
<tr>n
<td>说明:<td> <input type=text name='mess' size='100' value='$mess'></tr>n
<tr>n
<td>来自:<td> <input type=text name='fromx' size='100' value='$fromx'></tr>n
<tr>n
<td>图片url地址:<td> <input type=text name='url1' size='100' value='$url1'></tr>n
<tr>n
<td>说明:<td> <input type=text name='mess1' size='100' value='$mess1'></tr>n
<tr>n
<td>来自:<td> <input type=text name='fromx1' size='100' value='$fromx1'></tr>n
<tr>n
<td>图片url地址:<td> <input type=text name='url2' size='100' value='$url2'></tr>n
<tr>n
<td>说明:<td> <input type=text name='mess2' size='100' value='$mess2'></tr>n
<tr>n
<td>来自:<td> <input type=text name='fromx2' size='100' value='$fromx2'></tr>n
<tr>n
<td>图片url地址:<td> <input type=text name='url3' size='100' value='$url3'></tr>n
<tr>n
<td>说明:<td> <input type=text name='mess3' size='100' value='$mess3'></tr>n
<tr>n
<td>来自:<td> <input type=text name='fromx3' size='100' value='$fromx3'></tr>n
</table>n
<input type=submit value='更新'>n
</form>n";
}
else
{?>
<h3>请输放需要更改的id:</h3>
<center><form action='ww.php' method='post'>
<br>
动漫桌布
<input type="radio" name="jpg" value="jpg" checked>
平分秋色水彩画
<input type="radio" name="jpg" value="jpg1">
明星写真
<input type="radio" name="jpg" value="jpg2">
广告创意
<input type="radio" name="jpg" value="jpg3">
其它类
<input type="radio" name="jpg" value="jpg4">
<br>
<input type=text name='id'>
<input type=submit value='查询'>
</form></center>

<?}?>


</body>
</html>


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |