mardi 18 décembre 2018

php if else statement not displayingh

the if else statement is not displaying on my browser.I am currently making a profile page. When the first time i run it, it could display. But the file was corrupted and i had to code it again, since that it couldnt display the user profile.

Can anyone help me check for error? I've been checking for 4 hrs straight and i cant find anything because the browser did not output any php errors.

   <div class="col-sm-6">

    <?php
    global $con;

    if(isset($_GET['u_id'])) {
        $u_id = $_GET['u_id'];
    }

    $get_posts = " SELECT * FROM posts WHERE user_id='u_id' ORDER by 1 DESC LIMIT 5";

    $run_posts = mysqli_query($con, $get_posts);

    while ($row_posts = mysqli_fetch_array($run_posts)) {

        $post_id = $row_posts['post_id'];
        $user_id = $row_posts['user_id'];
        $content = $row_posts['post_content'];
        $upload_image = $row_posts['upload_image'];
        $post_date = $row_posts['post_date'];

        $user = "SELECT * FROM users WHERE user_id='$user_id' AND posts='yes'";

        $run_user = mysqli_query($con, $user);
        $row_user = mysqli_fetch_array($run_user);

        $user_name = $row_user['user_name'];
        $user_image = $row_user['user_image'];

        if($content=="No" && strlen($upload_image) >= 1) {
            echo "
            <div id='own_posts'>
                <div class='row'>
                    <div class='col-sm-2'>
                    <p><img src='users/$user_image' class='img-circle' width='100px' height='100px'></p>
                    </div>
                    <div class='col-sm-6'>
                    <h3><a style='text-decoration:none; cursor:pointer;color #3897f0;' href='user_profile.php?u_id=$user_id'>$user_name</a></h3>
                        <h4><small style='color:black;'>Updated a post on <strong>$post_date</strong></small></h4>
                    </div>
                    <div class='col-sm-4'>
                    </div>
                </div>
                <div class='row'>
                    <div class='col-sm-2'>
                        <img id='posts-img' src='imagepost/$upload_image' style='height:350px;'>
                    </div>
                </div><br>
                <a href='single.php?post_id=$post_id' style='float:right;'><button class='btn btn-success'>View</button></a><br>
                <a href='functions/delete_post.php?post_id=$post_id' style='float:right;'>
                <button class='btn btn-danger'>Delete</button></a><br>
            </div><br><br>


            ";
        }

The rest below is the else if and another 'else' which is basically the same as above.

Aucun commentaire:

Enregistrer un commentaire