Displaying a user's uploaded posts I'm working on prepared statements for my website and I'm wondering if it's possible to have multiple prepared statements one after another.  In this example, I have 2 select statements. I'm hoping that the question marks I have as placeholders won't be overwriting one another.  After that's been answered, I was wondering if this code was still open to SQL injection.  

function getHomeUploads($conn) {
        $userName = $_GET["user"];
        $sqluserid = "SELECT * FROM users WHERE userName = ?;";
        $useridstmt = mysqli_stmt_init($conn);
        if (!mysqli_stmt_prepare($useridstmt, $sqluserid)) {
            echo "SQL statement failed";
        }
        else {
            mysqli_stmt_bind_param($useridstmt, "s", $userName);
            mysqli_stmt_execute($useridstmt);

            $useridresult = mysqli_stmt_get_result($useridstmt);
            while ($useridrow = mysqli_fetch_assoc($useridresult)) {

                if($useridrow['userid'] &gt; 0) {
                    $userid = $useridrow['userid'];
                    $sqlusercontent = "SELECT * FROM posts WHERE hostid = ? AND userid = ? AND commentid = 0;";
                    $stmtusercontent = mysqli_stmt_init($conn);
                    if (!mysqli_stmt_prepare($stmtusercontent, $sqlusercontent)) {
                        echo "SQL statement failed";
                    }
                    else {
                        mysqli_stmt_bind_param($stmtusercontent, "ss", $userid, $userid);
                        mysqli_stmt_execute($stmtusercontent);
                        $usercontent = mysqli_stmt_get_result($stmtusercontent);
                        $postid = 1;

                        echo "&lt;div class='homepostcontainer'&gt;";
                        echo "&lt;div class='homepostcontainerscroll'&gt;";
                        while ($row = mysqli_fetch_assoc($usercontent)) {
                            // Text fileid
                            if ($row['fileid'] == 1) {
                                echo "&lt;div class='postbox'&gt;";
                                echo "&lt;div class='postscroll'&gt;";
                                echo $row['title']."&lt;br&gt;";
                                echo $row['date']."&lt;br&gt;";
                                echo $row['description']."&lt;br&gt;";
                                echo "&lt;/div&gt;";
                                echo "&lt;div class='InfoBar'&gt; &lt;a href=view.php?user=".$userName."&amp;post=".$postid."&gt;•••&lt;/a&gt; &lt;/div&gt;";
                                echo "&lt;/div&gt;";
                            }
                            // Picture fileid
                            else if ($row['fileid'] == 2) {
                                $filename = "posts/".$userid."/".$postid."*";
                                $fileinfo = glob($filename);
                                $fileext = explode(".", $fileinfo[0]);
                                $fileactualext = $fileext[1];

                                echo "&lt;div class='postbox'&gt;";
                                echo "&lt;div class='postscroll'&gt;";
                                echo $row['title']."&lt;br&gt;";
                                echo $row['date']."&lt;br&gt;";
                                echo "&lt;img src='posts/".$userid."/".$postid.".".$fileactualext."'&gt;&lt;br&gt;";
                                echo $row['description']."&lt;br&gt;";
                                echo "&lt;/div&gt;";
                                echo "&lt;div class='InfoBar'&gt; &lt;a href=view.php?user=".$userName."&amp;post=".$postid."&gt;•••&lt;/a&gt; &lt;/div&gt;";
                                echo "&lt;/div&gt;";
                            }
                            else {
                                echo '';
                            }

                            $postid++;
                        }
                        echo "&lt;/div&gt;";
                        echo "&lt;/div&gt;";  
                    }   
                }
            }
        }
    }
```
Passing the database connection as a variable is a good technique.
Validate user input as much as possible before considering executing any processes.  If the input is missing or invalid, don't do anything with the submission.

if (empty($_GET["user"])) { // add your validation here if possible
    echo "Missing/Invalid data submitted";
    // halt the script or redirect or whatever
}

Use object-oriented mysqli syntax because it is more brief and IMO cleaner to read.
Do not perform iterated queries.  You can easily condense you iterated queries into one simple query using an INNER JOIN.  Something like this should do (untested):

SELECT *
FROM users u
INNER JOIN posts p USING userid 
WHERE u.user_name = ?
  AND p.hostid = p.userid
  AND p.commentid = 0


USING is a convenient shorthand keyword when the two joining columns are identical; otherwise use ON and declare the columns individually. MySQL ON vs USING? You should also replace * in the SELECT clause with the exact columns you need from either table.  (Never ask for more than you need.) With the above query, you will only need to bind $_GET"user"] once since there is now only one placeholder.
I don't typically endorse printing from the same function that does the processing.  If you are going to print nested html elements, you can improve readability by tabbing them.
There is a cleaner way to extract the file extension than picking up post-explosion debris.  How do I get (extract) a file extension in PHP?

$ext = pathinfo($filename, PATHINFO_EXTENSION);

If $row['fileid'] isn't 1 or 2, don't bother printing an empty string.