简体   繁体   中英

i am geeting the error where the HTML form elements are not getting loaded into the webpage .Any solution for the below code

below in the image i am getting only the 3 form elements but there are more.I am unable to find the error where it is occuring.please help me to get the solution. It is a basic html form there are like 10 form elements but when i connected it with the database and ran the code only the first 3 form elements are getting displayed. It is basically connected to mysql data base in the backend and is a blog websites admin panel.

 <?php
        require "<includes/dbh.php";
 
        ?>
        <!DOCTYPE html>
        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta charset="utf-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <title>Free Bootstrap Admin Template : Dream</title>
            <!-- Bootstrap Styles-->
            <link href="assets/css/bootstrap.css" rel="stylesheet" />
            <!-- FontAwesome Styles-->
            <link href="assets/css/font-awesome.css" rel="stylesheet" />
                <!-- Custom Styles-->
            <link href="assets/css/custom-styles.css" rel="stylesheet" />
            <!-- Google Fonts-->
        <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
        </head>
        <body>
            <div id="wrapper">
                <?php include "header.php"; include "sidebar.php" ?>
                <div id="page-wrapper" >
                    <div id="page-inner">
                    <div class="row">
                            <div class="col-md-12">
                                <h1 class="page-header">
                                    Write a Blog on spot
                                </h1>
                            </div>
                        </div> 
                        <!-- /. ROW  -->
                    <div class="row">
                        <div class="col-lg-12">
                            <div class="panel panel-default">
                                <div class="panel-heading">
                                    Write a blog
                                </div>
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <form role="form" method="POST" action="includes/add-blog.php" enctype="multipart/form-data">
                                                <div class="form-group">
                                                    <label>Title</label>
                                                    <input class="form-control" name="blog-title">
                                                
                                                </div>
                                                <div class="form-group">
                                                    <label>Meta Title</label>
                                                    <input class="form-control" name="blog-meta-title">
                                                
                                                </div>
                                                <div class="form-group">
                                                    <label>Blog category</label>
                                                    <select class="form-control" name="blog-category">
                                                        
                                                        <?php
                                                        $sqlCategories="SELECT * FROM blog-category";
                                                        $queryCategories=mysqli_query($conn,$sqlCategories);
                                                        while($rowCategories=mysqli_fetch_assoc($queryCategories)){
                                                            $cId=$rowCategories['n_category_id'];
                                                            $cName=$rowCategories['v_category_title'];
                                                            echo "<option value='".$cId."'>".$cName."</option>";
                                                        }
                                                        ?>
                                                        
                                                    </select>
                                                </div>
                                                
                                                
                                                <div class="form-group">
                                                    <label>Main image</label>
                                                    <input type="file" name="main-blog-image">
                                                </div>
                                                <div class="form-group">
                                                    <label>Alternate image</label>
                                                    <input type="file"name="alt-blog-image">
                                                </div>
                                                <div class="form-group">
                                                    <label>summary</label>
                                                    <textarea class="form-control" rows="3"name="blog-summary"></textarea>
                                                </div>
                                            
                                                <div class="form-group">
                                                    <label>Blog content</label>
                                                    <textarea class="form-control" rows="3" name="blog-content"></textarea>
                                                </div>
                                                <div class="form-group">
                                                    <label>Blog Tags seperated by commas</label>
                                                    <textarea class="form-control" rows="3" name="blog-tags"></textarea>
                                                </div>
                                                <div class="form-group input-group">
                                                <label>Blog path</label>
                                                <div class="input-group"> <span class="input-group-addon">www.sjg.com/</span>
                                                    <input type="text" class="form-control" placeholder="username" name="blog-path"></div>
                                                
                                                </div>
 
                                                <div class="form-group">
                                                    <label>Home Page Placement</label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="blog-home-page-placement" id="optionsRadiosInline1" value="option1" checked="">1
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="blog-home-page-placement" id="optionsRadiosInline2" value="option2">2
                                                    </label>
                                                    <label class="radio-inline">
                                                        <input type="radio" name="blog-home-page-placement" id="optionsRadiosInline3" value="option3">3
                                                    </label>
                                                </div>
                                                
                                                
                                                <button type="submit" class="btn btn-default" name="submit-blog">Add Blog</button>
                                                
                                            </form>
                                        </div>
                                        
                                    
                                    </div>
                                    <!-- /.row (nested) -->
                                </div>
                                <!-- /.panel-body -->
                            </div>
                            <!-- /.panel -->
                        </div>
                        <!-- /.col-lg-12 -->
                    </div>
                <?php include "footer.php"; ?>
                    </div>
                    <!-- /. PAGE INNER  -->
                    </div>
                <!-- /. PAGE WRAPPER  -->
                </div>
            <!-- /. WRAPPER  -->
            <!-- JS Scripts-->
            <!-- jQuery Js -->
            <script src="assets/js/jquery-1.10.2.js"></script>
            <!-- Bootstrap Js -->
            <script src="assets/js/bootstrap.min.js"></script>
            <!-- Metis Menu Js -->
            <script src="assets/js/jquery.metisMenu.js"></script>
            <!-- Custom Js -->
            <script src="assets/js/custom-scripts.js"></script>
            
        
        </body>
        </html>

在此处输入图像描述

Above in the image i am getting only the 3 form elements but there are more.I am unable to find the error where it is occuring.please help me to get the solution. It is a basic html form there are like 10 form elements but when i connected it with the database and ran the code only the first 3 form elements are getting displayed. It is basically connected to mysql data base in the backend and is a blog websites admin panel.

Judging by where the page stops rendering, there's likely an error where your category dropdown is being populated. To check this you could add <?php error_reporting(E_ALL); ?> <?php error_reporting(E_ALL); ?> to the top of your file. Check the error_reporting docs here .

I'd also like to second @CBroe's observation that require "<includes/dbh.php"; doesn't look correct. Properly including that file may allow the category generation to occur and allow for the rest of the document to populate.


I'd also like to add that echo "<option value='".$cId."'>".$cName."</option>"; could be written as echo "<option value='{$cId}'>{$cName}</option>"; to help with human readability, if you so desired.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM