This is an issue with understanding the mysqli_stmt
documentation, which includes pages for each of the functions below.
A SELECT
query will not affect any rows.
Looking in the manual at [php docs for mysqli affected-rows]. Under Return values:
-1 indicates that the query returned an error.
However, this is really a mixed question.
To get the number of rows, try:
$query = "SELECT * FROM `sk_courses`"; // or
$query = "SELECT lastName, firstName, ... FROM `sk_courses`";
$stmt = $mysqli->prepare($query);
$stmt->execute();
$stmt->store_result(); // without this line, num_rows = 0
print $stmt->num_rows;
Then, if interested in the result set set, add:
// bind result variables. next statement 'binds' them in the order of the select query
$stmt->bind_result($last, $first, .... ); // must have variable for EACH column
while ($stmt->fetch()) {
printf ("%s (%s)\n", $first, $last);
}