php案頭中心(三) 修改資料庫

來源:互聯網
上載者:User

下面這個程式在你輸入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>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.