繁体   English   中英

我收到 HTML 表单元素未加载到网页中的错误。以下代码的任何解决方案

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

在图片下方,我只获得了 3 个表单元素,但还有更多。我无法找到它发生的错误。请帮助我获得解决方案。 这是一个基本的 html 表单,有大约 10 个表单元素,但是当我将它与数据库连接并运行代码时,只显示前 3 个表单元素。 它基本上连接到后端的 mysql 数据库,是一个博客网站管理面板。

 <?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>

在此处输入图像描述

在图像上方,我只得到了 3 个表单元素,但还有更多。我无法找到它发生的错误。请帮助我获得解决方案。 这是一个基本的 html 表单,有大约 10 个表单元素,但是当我将它与数据库连接并运行代码时,只显示前 3 个表单元素。 它基本上连接到后端的 mysql 数据库,是一个博客网站管理面板。

从页面停止呈现的位置判断,您的类别下拉列表可能存在错误。 要检查这一点,您可以添加<?php error_reporting(E_ALL); ?> <?php error_reporting(E_ALL); ?>到文件的顶部。 在此处查看error_reporting文档

我还想支持@CBroe 的require "<includes/dbh.php";的观察。 看起来不正确。 正确包含该文件可能允许发生类别生成并允许填充文档的 rest。


我还想添加echo "<option value='".$cId."'>".$cName."</option>"; 可以写成echo "<option value='{$cId}'>{$cName}</option>"; 如果您愿意,可以帮助提高人类可读性。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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