儘管之前已經提出過這個問題的變化,但他們都沒有幫助我解決這個難題。目前我已經把表格放在一起更新了數據庫等等,問題是當我去編輯字段時,只有第一部分數據被顯示,例如,如果數據是'晴天',那麼當我點擊編輯這個字段,我會得到的是'Sunny',那麼如果我點擊更新,它會將數據庫編輯回Sunny。我錯過了什麼?!只會顯示mysql_fetch_array的第一部分
在此先感謝。只有
// Connects to your Database
$query=mysql_connect("localhost", "cl52-abcdef","abcdef") or die(mysql_error());
mysql_select_db("cl52-abcdef",$query);
?>
<html>
<body>
<?php
if(isset($_GET['id']))
{
$id=$_GET['id'];
if(isset($_POST['submit']))
{
$holdesc1=$_POST['holdesc1'];
$holdest1=$_POST['holdest1'];
$rrp1=$_POST['rrp1'];
$cpe1=$_POST['cpe1'];
$ea1=$_POST['ea1'];
$query3=mysql_query("update DealOne set holdesc1='$holdesc1',holdest1='$holdest1',rrp1='$rrp1',cpe1='$cpe1',ea1='$ea1' where id='$id'");
if($query3)
{
header('location:list.php');
}
}
$query1=mysql_query("select holdesc1, holdest1, rrp1, cpe1, ea1 from DealOne where id='$id'");
$query2=mysql_fetch_array($query1);
?>
<form method="post" action="">
1 <input type="text" value=<? echo $query2['holdesc1']; ?> name="holdesc1"><br>
2 <input type="text" value=<? echo $query2['holdest1']; ?> name="holdest1"><br>
3 <input type="text" value=<? echo $query2['rrp1']; ?> name="rrp1"><br>
4 <input type="text" value=<? echo $query2['cpe1']; ?> name="cpe1"><br>
5 <input type="text" value=<? echo $query2['ea1']; ?> name="ea1"><br><br>
<input type="submit" name="submit" value="update" />
</form>
<?php
}
?>
</body>
</html>
'mysql_query'已被棄用一段時間了。切換到mysqli或PDO。 – cHao
是的 - 您在'value'屬性中缺少引號。你必須引用它們作爲'value =「<?php echo htmlspecialchars($ query2 [...],ENT_QUOTES);?>」'查看瀏覽器的頁面源代碼,你會發現問題所在。 –
你是說你的數據在第一個空格之前總是被截斷? – LoganEtherton