I am not able to show the data from DB to page and getting
Notice: Undefined variable: id
This is my code
<?php
            if (isset( $_GET[ 'id' ] ) ) {
                $id = $_GET[ 'id' ];
            }
            $query2 ="select * from video where vid='$id'";
            $sql2 = mysqli_query( $con, $query2 );
            $row2 = mysqli_fetch_assoc( $sql2 );
            ?>
            <iframe src="https://www.youtube.com/embed/<?php echo $row2['link'];?>" height="300" width="400" scrolling="no" frameborder="0"></iframe>
            <h1>
                <?php echo $row2['title'];?>
            </h1>
            <p>
                <?php echo $row2['description'];?>
            </p>
        <div class="comment">
            <p>
                <?php echo $row4['comment'];?>
            </p>
            <p>
                <?php echo "From ". $row4['uid'];?>
            </p>
        </div>
        <?php
        }
        }
        if ( isset( $_POST[ 'submit' ] ) ) {
            if ( empty( $_POST[ 'email' ] ) || empty( $_POST[ 'comment' ] ) ) {
                $erro = "<p class='text-danger'> Fill the Required Fields</p>";
            } else {
                $Commentquery = "insert into comments (vid,uid,status,comments,datetime) values ('$id','$_POST[email]', 'pending','$_POST[comment]',now())";
                if ( mysqli_query( $con, $Commentquery ) ) {
                    $sucess = "<p class='text-sucess'> Thankyou</p>";
                }
            }
        }
        ?>
        <div class="comment_form">
            <h2> Comment on post</h2>
            <?php
            if ( isset( $err ) ) {
                echo $err;
            }
            if ( isset( $sucess ) ) {
                echo $sucess;
            }
            ?>
            <form method="post" action="">
                <div class="form-group">
                    <lable> Email Address</lable>
                    <input type="email" name="email" class="form-control"/>
                </div>
                <div class="form-group">
                    <lable> Comment</lable>
                    <textarea name="comment" class="form-control" cols="40" rows="4"></textarea>
                </div>
                <div class="form-group">
                    <input type="submit" name="submit" class="btn btn-default"/>
                </div>
            </form>
        </div>
Can any one tell me what wrong thing I am doing?
i have updated the code and added the $id = -1; as you told me the error is gone but started getting this error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\site\admin\post.php on line 41
the line which is -
if ( mysqli_num_rows( $sql ) > 0 ) {
                while ( $row4 = mysqli_fetch_array( $sql ) ) {
                    ?>
you can see it in the code also please let me know why the id is creating the issue
 
     
    