1. Are you ready for the Galaxy S20? Here is everything we know so far!

Apps mysqli prepared statement

Discussion in 'Android Development' started by Thayar, Aug 5, 2013.

  1. Thayar

    Thayar Newbie
    Thread Starter

    i'm using the below code for fetch the values using prepared statement.

    i want to write these code as function so that i can call these function where ever i want.

    while i'm calling function i can pass the query as parameters
    how can i pass values for bind param?


    //code starts

    if($stmt=$mysqli->prepare("select xx,yy from sampletbl where xx=? or yy =?"))
    {
    $stmt->bind_param("ss",$value1,$value2);
    if($stmt->execute())
    {
    $result=$stmt->get_result();
    while($value=$result->fetch_assoc())
    {
    $printval[]=$value;
    }
    echo json_encode($printval);
    }
    else
    {
    echo "doesn't execute";
    }
    }

    //code ends
     

    Advertisement

Loading...

Share This Page

Loading...