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
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