zoukankan      html  css  js  c++  java
  • php :: mysql

     

    mysql_php 大全

    <?php
        $con = mysql_connect("localhost", "root", "dami");
        if(!$con)
        {
            die('不能连接到指定数据库');
        }
        mysql_select_db("lesson", $con);
        //mysql_query("insert into student values(226,'书籍',26,'this is description')");
        //mysql_query("update student set des = 'the des of joan' where id = 2");
        //mysql_query("delete from student where id = 226");
        $result = array();
        $result_temp = mysql_query("select * from student");
        while($row = mysql_fetch_array($result_temp))
            $result[] = $row;
        //print_r($result);
        foreach($result as $index => $student)
        {
            echo "$index 
    ";
            print_r($student);
            echo "
    ";
        }
        //var_dump($result);
        mysql_close($con);
    ?>

    $con = mysql_connect("localhost", "root", "abc123");    //建立数据库连接

    mysql_select_db("db_name", $con);                                       //选择数据库

    mysql_query("select * from student", $con);        // 数据库查询

    mysql_query("insert into student(id,name) values(2,'student_one_name')");   //插入数据

    //mysql_query获取的数据处理

    while($row = mysql_fetch_array($result))

      $result[] = $row;

    mysql_close($con);                  //数据库连接关闭

    修改列属性默认值: alter table t_sap_account_history alter column check_status set default 0

  • 相关阅读:
    List,Set,Map初级学习
    String,StringBuffer,StringBuilder 的使用
    activity跳转
    JSON与List之间的转换
    子线程更新UI
    数据库查询关键字显示所有结果
    Java数据类型转换1
    git 操作
    MySql导出表结构
    springBoot双数据源配置
  • 原文地址:https://www.cnblogs.com/maxiaoshuai/p/6824924.html
Copyright © 2011-2022 走看看