Created
August 31, 2014 08:48
-
-
Save QETHAN/1922f40ceaf88d1b0ac1 to your computer and use it in GitHub Desktop.
php 插入数据
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//连接数据库 | |
mysql_connect('127.0.0.1', 'code1', ''); | |
mysql_select_db('code1'); | |
mysql_query("set names 'utf8'"); | |
//预设数据以便进行更新操作 | |
mysql_query("insert into user(name, age, class) values('王二', 19, '高三五班')"); | |
$id = mysql_insert_id(); | |
//在这里更新id为$id的行的名字为李白 | |
//输出更新数据条数 | |
echo '数据更新行数:'.mysql_affected_rows(); | |
mysql_query("delete from user where id='$id'"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment