Below is the code I am using. Separately they both do what they are supposed to but when I try to use the result from the first statement in the second it doesn't return anything. I know that The first statement always returns the correct data. Can someone tell me what it is I'm doing wrong? Thanks
$connection = mysqli_connect($hostname, $username, $password, $dbname);
$sql = "SELECT banner".$number_id."_id FROM newcms_projectbanners WHERE region_id = ?";
$stmt = mysqli_prepare($connection, $sql);
mysqli_stmt_bind_param($stmt, "s", $region_id);
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $banner_id);
// display the results
mysqli_stmt_fetch($stmt);
$sql1 = "SELECT `title`, `active`, `linkto` FROM newcms_banners WHERE id = ?";
$stmt1 = mysqli_prepare($connection, $sql1);
mysqli_stmt_bind_param($stmt1, "s", $banner_id);
mysqli_stmt_execute($stmt1);
mysqli_stmt_bind_result($stmt1, $title, $active, $linkto);
// display the results
mysqli_stmt_fetch($stmt1);
EDIT
Upon further inspection, it seems that I can't run two statements in this fashion. What is the correct way of doing it? Thanks