HTML填充MySQL数据

时间:2017-04-04 10:39:01

标签: php html mysql

我需要一些帮助,我需要如何在HTML属性值中设置MySQL数据。 在我的表单中,我想用MySQL数据填充它,但它不起作用...... 我已经阅读了很多关于如何将其填入HTML属性" value",但它并没有帮助我。现在我绝望了我做错了什么。

整个守则:

<?php 
include("./config/plugins/samp_viewer.php");
$viewer = new SAMPViewer();
$viewer->SAMPConnection();
// That was wrong, it works on the HTML Section ...
#$query  =   $connect->prepare("SELECT * FROM `ucp_samp` WHERE `id` = 1 LIMIT 1");
#$query->execute();
#$fetch  =   $query->fetch();
?>

<div class="wrapper">
    <?php include("templates/acp_header.php"); ?>        
    <?php include("templates/acp_navbar.php"); ?>

    <div class="content-wrapper">
        <section class="content-header">
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> Übersicht</a></li>
            </ol><br/>
        </section>

        <section class="content"> 
            <?php if(isset($_GET[md5("message=success")])) echo "<div class='alert alert-success' id='alert'><i class='fa fa-check'></i> SAMP Viewer wurde <b>erfolgreich</b> bearbeitet.</div>"; ?>
            <?php if(isset($error_msg)) echo "<div class='alert alert-danger'><i class='fa fa-close'></i> $error_msg</div"; ?>

            <div class="row">
<?php
$query  =   $connect->prepare("SELECT * FROM `ucp_samp` WHERE `id` = 1 LIMIT 1");
$query->execute();
$fetch  =   $query->fetch(); ?>
                <section class="col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title"><i class="fa fa-signal"></i> SAMP Viewer</h3>
                        </div>
                        <div class="box-body">
                            <?php if($samp_query->isOnline() != 1) echo "<div class='alert alert-warning'><i class='fa fa-warning'></i> Verbindung zum SA:MP Server <b>fehlgeschlagen</b>.</div>"; ?>
                            <form action="" method="post" autocomplete="off">
                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-signal"></i></span>
                                        <input type="text" class="form-control" name="serverip" value="<?php echo htmlentities($fetch['IP']); ?>" placeholder="Server IP ..."/>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-at"></i></span>
                                        <input type="text" class="form-control" name="serverport" value="<?php echo htmlentities($fetch["Port"]); ?>" placeholder="Server Port ..."/>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <button class="btn btn-success btn-block" name="submit1">Speichern</button>
                                </div>
                            </form>

                            <form action="" method="post" autocomplete="off">
                                <div class="form-group">
                                    <label>SAMP Viewer Status</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-sliders"></i></span>
                                        <select class="form-control" name="active">
                                            <option value="1" <?php if($fetch["active"] == 1) echo "selected"; ?>>Aktivieren</option>
                                            <option value="-1" <?php if($fetch["active"] == -1) echo "selected"; ?>>Deaktivieren</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label>Spielertabelle</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-sliders"></i></span>
                                        <select class="form-control" name="userlist">
                                            <option value="1" <?php if($fetch["userlist"] == 1) echo "selected"; ?>>Aktiviert</option>
                                            <option value="-1" <?php if($fetch["userlist"] == -1) echo "selected"; ?>>Deaktiviert</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label>Hostedtabelle</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-sliders"></i></span>
                                        <select class="form-control" name="hostedlist">
                                            <option value="1" <?php if($fetch["hostedlist"] == 1) echo "selected"; ?>>Aktiviert</option>
                                            <option value="-1" <?php if($fetch["hostedlist"] == -1) echo "selected"; ?>>Deaktiviert</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label>Signaturgenerator Status</label>
                                    <div class="input-group">
                                        <span class="input-group-addon"><i class="fa fa-sliders"></i></span>
                                        <select class="form-control" name="signatur">
                                            <option value="1" <?php if($fetch["signatur"] == 1) echo "selected"; ?>>Aktivieren</option>
                                            <option value="-1" <?php if($fetch["signatur"] == 1) echo "selected"; ?>>Deaktivieren</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <button class="btn btn-success btn-block" name="submit2">Speichern</button>
                                </div>
                            </form>
                         </div>
                    </div>
                </section>
            </div>
        </section>
    </div>
    <footer class="main-footer footer-fixed">
        <div class="pull-right hidden-xs">
            <b>UCP-Version</b> <?php echo UCPVersion(); ?>
        </div>
        <strong>Copyright &copy; 2016 <a href="http://vare-design.de">vare-design.de</a>.</strong>
    </footer>
</div>

0 个答案:

没有答案