• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps mysqli prepared statement

Thayar

Newbie
Jul 15, 2013
17
0
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
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones