Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created August 31, 2014 08:48
Show Gist options
  • Save QETHAN/1922f40ceaf88d1b0ac1 to your computer and use it in GitHub Desktop.
Save QETHAN/1922f40ceaf88d1b0ac1 to your computer and use it in GitHub Desktop.
php 插入数据
<?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