I wanted to make my SQL query into a prepared statement but realized, that it wasn't as easy as I first thought. Here is the query in its current form, so not as prepared statement.
$mysqli = new mysqli(...);
$result = mysqli_query( $mysqli,
"SELECT count(*) as total from test_users, image_uploads
WHERE test_users.APPROVAL = 'granted'
AND test_users.NAME = image_uploads.OWNER
AND (test_users.IMGAUTO = 'enabled' OR image_uploads.IAPPROVAL = 'granted')
");
$data = mysqli_fetch_assoc( $result );
$row_cnt = $data['total'];
$totalPages = ceil(($row_cnt / $cardmax));
So my problem now is this. When I make the prepared statement, I'm not going to be able to access image_uploads.OWNER anymore since I use it inside the query at the moment.
$grant = 'granted';
$owner = ""; //<<--- how to get image_uploads.OWNER
$enabl = 'enabled';
$sql =
"SELECT COUNT(*) FROM test_users, image_uploads
WHERE test_users.APPROVAL=?
AND test_users.NAME=?
AND (test_users.IMGAUTO=? OR image_uploads.IAPPROVAL=?)
";
$stmt = $mysqli->prepare($sql);
$stmt->bind_param('ssss', $grant, $owner, $enabl, $grant);
$stmt->execute();
$row = $stmt->get_result()->fetch_row();
$row_cnt = $row[0];
$totalPages = ceil(($row_cnt / $cardmax));
Is there a method to get this image_uploads.OWNER in my prepared statement. How do I do this correctly?