Let's say I have a prepared statement, in this case, one that selects photo information from a specific table in a database:
$conn = dbConnect('query');
$bgImage = "SELECT photo_fname
FROM photos_bn
WHERE gallery_id = ?
LIMIT $curPage,".$totalPix;
$stmt = $conn->prepare($bgImage);
$stmt->bind_param('i', $gallery);
$stmt->bind_result($pFname);
$stmt->execute();
$stmt->store_result();
$stmt->fetch();
And since I have several tables in my database that deal with specific photo themes, one would assume I would need separate queries for each table. The above code selects information from the table, photos_bn
, but I have other tables, we'll call them, photos_bq
and photos_ps
.
This may be an insanely obvious question, but how would I go about replacing the table name with a variable that could be passed to the page via query string or session variable so that the table name in the query is not hard coded, but is part of a prepared statement?
Many thanks!