Mysqli_query result to variable PHP [duplicate]

2019-08-12 02:32发布

问题:

This question already has an answer here:

  • Fetching one row only with MySQLi 1 answer

I've tried looking around and couldn't find an answer myself, so I'll post my problem instead, maybe it will help other people :)

I'm making a mysql query and getting an array out of it as it's supposed to do, but I want to take my first result out of this array and put that result in a variable instead so I can use it in my logic.

$conn = new mysqli($servername, $username, $password, $dbname);
$value_High = mysqli_query($conn, "SELECT MAX(picID) from pictures");
$id = mysqli_data_seek($value_High, 0);
var_dump($id);

I've tried some different things, I get a bool out of myqli_data_seek which is not what I want ofc, so I obviously need to use something else, I just don't know what.

回答1:

$id = mysqli_fetch_row($value_High);


标签: php mysql mysqli