Код: Выделить всё
$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);
Подробнее здесь: https://stackoverflow.com/questions/233 ... -statement