Proszę o uwagę co mam poprawić aby kod zadziałał

$result = mysqli_query($connect, $query); $posts = mysqli_fetch_all($result, MYSQLI_ASSOC); if(mysqli_num_rows($posts > 0) { foreach ($posts as $post) { ?> $output .= '<div class="well well-lg"><h3>'; $output .= '</h3> <span class="glyphicon"></span> <small> '; $output .= ' </small> <p>'; <php }} endforeach; echo $output; } else { echo "brak rekordów"; } ?>