程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php update數據更新簡單實例

php update數據更新簡單實例

編輯:關於PHP編程

sql update記錄更新詳細實例

語法:

[ WITH <common_table_expression> [...n] ]
UPDATE
    [ TOP (expression) [ PERCENT ] ]
    { { table_alias | <object> | rowset_function_limited
         [ WITH ( <Table_Hint_Limited> [ ...n ] ) ]
      }
      | @table_variable   
    }
    SET
        { column_name= { expression | DEFAULT | NULL }
          | { udt_column_name.{ { property_name= expression
                                | field_name=expression }
                                | method_name(argument [ ,...n ] )
                              }
            }
          | column_name { .WRITE (expression,@Offset,@Length) }
          | @variable=expression
          | @variable= column=expression
          | column_name { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable { += | -= | *= | /= | %= | &= | ^= | |= } expression
          | @variable=column { += | -= | *= | /= | %= | &= | ^= | |= } expression
        } [ ,...n ]

    [ <OUTPUT Clause> ]
    [ FROM { <table_source> } [ ,...n ] ]
    [ WHERE { <search_condition>
            | { [ CURRENT OF
                  { { [ GLOBAL ] cursor_name }
                      | cursor_variable_name
                  }
                ]
              }
            }
    ]
    [ OPTION ( <query_hint> [ ,...n ] ) ]
[ ; ]

<object> ::=
{
    [ server_name . database_name . schema_name .
    | database_name .[ schema_name ] .
    | schema_name .
    ]
    table_or_view_name}

實例 php教程

<?php
   mysql教程_connect("mysql153.secureserver.net","java2s","password");
   mysql_select_db("java2s");

   $query = "UPDATE Employee SET salary = '39.99' ";
   $result = mysql_query($query);
   echo "There were ".mysql_affected_rows()." product(s) affected. ";

?>


利用update 更新數據

<?php

   mysql_connect("mysql153.secureserver.net","java2s","password");
   mysql_select_db("java2s");

   $rowID = "0001";
   $name = "Kate";
   $price = "12";

      $query = "UPDATE Employee SET name='$name', price='$price' WHERE ID='$rowID'";
      $result = mysql_query($query);

      if ($result)
         echo "<p>The developer has been successfully updated.</p>";
      else
         echo "<p>There was a problem updating the developer.</p>";

 

?>

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved