博客
关于我
PHP学习(五)
阅读量:130 次
发布时间:2019-02-26

本文共 1826 字,大约阅读时间需要 6 分钟。

MySQL ???????

MySQL ????

1. ?????

?? mysqli() ????????????

// ?????$mysql = new mysqli("localhost", "root", "root");if ($mysql->connect_error) {    die("????: " . $mysql->connect_error);}echo "?????";

2. ?????

???????????????????????

// ?????$sql = "CREATE DATABASE php";if ($mysql->query($sql) == true) {    echo "????????";} else {    echo "???????: " . $mysql->error;}

?????????

3. ?????

???????????

// ????$mysql = new mysqli("localhost", "root", "root", "php");if ($mysql->connect_error) {    die("????: " . $mysql->connect_error);}echo "?????";// ?????$sql1 = "CREATE TABLE user (    id INT unsigned AUTO_INCREMENT PRIMARY KEY,    pwd VARCHAR(20) NOT NULL)";if ($mysql->query($sql1) == true) {    echo "????????";} else {    echo "???????: " . $mysql->error;}// ????$sql2 = "INSERT INTO user VALUES('201801', '123456')";if ($mysql->query($sql2) == true) {    echo "???????";} else {    echo "??????: " . $mysql->error;}// ??????$sql3 = "INSERT INTO user VALUES('201802', '123456');";$sql3 .= "INSERT INTO user VALUES('201803', '123456');";if ($mysql->multi_query($sql3) == true) {    echo "?????????";} else {    echo "????????: " . $mysql->error;}

4. ?????

???????????????

// ?????$sql = $mysql->prepare("INSERT INTO user VALUES(?, ?)");$sql->bind_param("is", $id, $pwd);// ????$id = 201804;$pwd = "123456";if ($sql->execute()) {    echo "?????????";} else {    echo "????????";}

5. ????

?????????

// ????$sql = "SELECT * FROM user";$result = $mysql->query($sql);if ($result->num_rows > 0) {    while ($row = $result->fetch_assoc()) {        echo "????: id=" . $row["id"] . ", ??: " . $row["pwd"] . "
"; }}

Ajax ????

6. ????????

??Ajax?????????

???????????:

??:

???:

????

  • ?? mysqli() ???????????????
  • ???????????????????
  • ????????????????????
  • Ajax ???????????? gethint.php??????

转载地址:http://yxkf.baihongyu.com/

你可能感兴趣的文章
python stdout flush_sys.stdout.flush()方法的用法
查看>>
python string 运算
查看>>
Python str与bytes之间的转换
查看>>
Python subprocess ffmpeg
查看>>
python subprocess Permission denied Errno 13
查看>>
Python subprocess.call - 将变量添加到 subprocess.call
查看>>
Python Subprocess.Popen 从一个线程
查看>>
Python subprocess.Popen 作为 Windows 上的不同用户
查看>>
Python subprocess.Popen() 等待完成
查看>>
Python Sympy模块NoConversion:收敛到根失败;请尝试n<;15或MaxSteps>;50
查看>>
python time模块
查看>>
Python Tkinter Multiple Windows 教程
查看>>
Python tkinter 中的多处理
查看>>
Python tweepy写入到sqlite3 db
查看>>
Python TypeError:格式字符串的参数不足
查看>>
Python UI自动化测试Page Objects企业级实战
查看>>
python谷歌翻译,2021年9月10日亲测可用,一次可以翻译十万,强烈star
查看>>
Python UI自动化测试数据驱动实战
查看>>
Python UI自动化测试集成UnitTest
查看>>
Python UI自动化测试集成UnitTest
查看>>