<form method="post">
<p>id:<input type="text" name="id" /></p>
<p>length:<input type="text" name="length"</p>
<p>width:<input type="text" name = "width"</p>
<p>height:<input type="text" name="height"</p>
<br>;
<input type="submit" value="UPDATE" />
</form>
<?php
$con = mysqli_connect("localhost","root","CWT520","jiaju");
if(!$con)
{
die('Could not connect:'.mysql_error());
}
if (isset($_POST['id']))
{
mysqli_query($con, "UPDATE jiajudata SET width='".$_POST['width']."',
length='".$_POST['length']."',height='".$_POST['height']."',ID='".$_POST['id']."'
where id='".$_POST['id']."'");
}
//注意单引号与双引号;
$result mysqli_query($con,"SELECT * FROM jiajudata");
while($row = mysqli_fetch_array($result))
{
echo $row['ID'] ." ".$row['length']." ".$row['width']. " " . $row['height'];
echo "<br>";
}
mysqli_close($con);
<p>id:<input type="text" name="id" /></p>
<p>length:<input type="text" name="length"</p>
<p>width:<input type="text" name = "width"</p>
<p>height:<input type="text" name="height"</p>
<br>;
<input type="submit" value="UPDATE" />
</form>
<?php
$con = mysqli_connect("localhost","root","CWT520","jiaju");
if(!$con)
{
die('Could not connect:'.mysql_error());
}
if (isset($_POST['id']))
{
mysqli_query($con, "UPDATE jiajudata SET width='".$_POST['width']."',
length='".$_POST['length']."',height='".$_POST['height']."',ID='".$_POST['id']."'
where id='".$_POST['id']."'");
}
//注意单引号与双引号;
$result mysqli_query($con,"SELECT * FROM jiajudata");
while($row = mysqli_fetch_array($result))
{
echo $row['ID'] ." ".$row['length']." ".$row['width']. " " . $row['height'];
echo "<br>";
}
mysqli_close($con);
?>
新版mysqli_connect("('localhost', 'user', 'password','data_base');