PHP database additions and deletions to check the source code (2)

Source: Internet
Author: User
Tags php database printf

3. Update

<body>
<title>
Update
</title>

?
The beginning of the PHP program
$db = mysql_connect ("localhost", "root");
mysql_select_db ("MySite", $db);
if (! $id)
{
$result = mysql_query ("SELECT * from user", $db);
if ($myrow = mysql_fetch_array ($result))
{
printf ("

do {
printf ("%s<a href="%s?id=%s ">%s </a><br>\n",
$myrow ["id"], $PATH _info, $myrow ["id"], $myrow ["name"]);
}
while ($myrow = Mysql_fetch_array ($result));
}
Else
{
echo "I'm sorry!" No records in the database ";
}
}
Else
{
if ($submit)
{
$sql = "UPDATE user SET name= ' $name ', city= ' $city ',
Address= ' $address ', email= ' $email ' WHERE id= $id ';
$result = mysql_query ($sql);
echo "Thank you!" Data change complete \ n ";
}
Else
{
$sql = "SELECT * from user WHERE id= $id";
$result = mysql_query ($sql);
$myrow = Mysql_fetch_array ($result);
The following is not part of PHP
?>
&LT;H2 align=left> Please make changes to the user's information:<form method= "POST" action= " echo $PATH _info?> ">
<input type=hidden name= "id"
Value= "<?php echo $myrow [" id "]?>" >
Name: <input type= "Text" Name= "the" "Value=" <?php
echo $myrow ["name]?>" ><br>
Cities: <input type= "Text" name= "City" value= "<?php Echo
$myrow ["City"]?> "><br>
Address: <input type= "Text" name= "Addresses" value= "<?php Echo
$myrow ["Address"]?> "><br>
E-mail: <input type= "Text" name= "email" value= "<?php Echo
$myrow ["Email"]?> "><br>
<input type= "Submit" name= "submit" value= "Revised completed" >
</form>
?
The end of PHP
65:}
}
?>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.