PHP sqlsrv query to database

后端 未结 4 2179
独厮守ぢ
独厮守ぢ 2021-02-13 18:10

I am migrated from MySQL to MS SQL Server, and trying to fetch all data from the routines table. I am connected but unsure how to fetch data with sqlsrv. This is how far I have

4条回答
  •  渐次进展
    2021-02-13 18:33

    $conn_array = array (
        "UID" => "sa",
        "PWD" => "root",
        "Database" => "nih_bw",
    );
    $conn = sqlsrv_connect('BILAL', $conn_array);
    if ($conn){
        echo "connected";
        if(($result = sqlsrv_query($conn,"SELECT * FROM routines")) !== false){
            while( $obj = sqlsrv_fetch_object( $result )) {
                  echo $obj->colName.'
    '; } } }else{ die(print_r(sqlsrv_errors(), true)); }

    that work great for me, but please any one can help me to display the result on a table ?

    I mean this parts :

    while( $obj = sqlsrv_fetch_object( $result )) {
                  echo $obj->colName.'
    '; }

提交回复
热议问题