I have used prepare
, bind_param
, and execute
statements to query my database and get only the first column. In php, how would I store the 1st returned value as a string?
In this example of returned values, I would want to store value 1
as a string.
value 1
value 2
value 3
Actual code:
//connect to database
$var1 = a;
$var2 = b;
$var3 = c;
$var4 = d;
$var5 = e;
$stmt = $mysqli->prepare("SELECT id FROM id_list WHERE variable1 = ? && variable2 = ? && variable3 = ? && variable4 = ? && variable5 = ?");
$stmt->bind_param('sssss', $var1, $var2, $var3, $var4, $var5);
$stmt->execute();
//How would I get the result here?
$stmt->bind_result($result);
echo $result;