Mysqli - Bind results to an Array

后端 未结 5 1268
花落未央
花落未央 2020-12-07 03:41

I recently switched to mysqli from mysql and started using prepared statements. in mysql we do

$result = mysql_query(\"SELECT * FROM table WHERE id = ?\");
<         


        
5条回答
  •  不知归路
    2020-12-07 04:00

    Use Simply Like this

    $con=mysqli_connect( "$host", "$mysql_u", "$mysql_p","$mysql_db");/*these variables are ur host,username, password and db name*/
        $val="SELECT * FROM table";
        $ex=mysqli_query($con,$val);
        while ($row = mysqli_fetch_assoc($ex)) {
    
        $ans=$row['col1'];
        ....
        }
    

提交回复
热议问题