How to pass array in php PDO select query

Here I am using implode statement to qualification but i want to select that qualified people in the query…

I want to here show people who are all educated either SSLC or PUC or BCA …

    $my_explode=implode(",",$_SESSION['qualification']);

    eg:  $my_explode=SSLC,PUC,BCA
 	  
    $query1 = ' SELECT * FROM `tbl_user_reg`   WHERE    qualification in(:qualification) ';
    $query2 = $conn->prepare($query1);
    
    $query2->bindParam(':qualification',$my_explode);
    $query2->execute();
    $result = $query2->fetchAll(PDO::FETCH_ASSOC);
    foreach($result as $disel):

But here not working the query …,

any suggestion please…!

thanks,

Only values can be supplied via prepared query place-holders, not sql syntax. The commas between the values are part of the sql syntax. Therefore, you must supply a separate prepared query place-holder for piece of data.

This is actually addressed in the php.net documentation. See example #5 at this link - https://www.php.net/manual/en/pdostatement.execute.php

Sponsor our Newsletter | Privacy Policy | Terms of Service