这段代码有什么问题?数据不会显示

时间:2017-04-02 11:13:23

标签: php mysql

我必须添加通知,我可以选择任何一个。所以另一个仍为空。但是没有显示数据。 这是显示数据的页面。代码如下:

<!DOCTYPE html>
<html>
<head>
    <style>
        table, td, th {
            border: 1px solid black;
        }
    </style>
</head>
<body>
<?php
require('header.php');
require('sidebar.php');
$i=1;
include("conn.php");
$con2=new con_data();

$qry = "select bl.*,r.*,bs.*,rn.*,n.* from notification As n INNER JOIN registration As r INNER JOIN batch_schedule As bs
        INNER JOIN recipe_name As rn INNER JOIN blog As bl ON bl.Blog_ID=n.Blog_ID AND r.Reg_ID=n.Reg_ID AND
        bs.BSch_ID=n.BSch_ID AND rn.RecName_ID=n.RecName_ID " ;
echo $qry;
$res=$con2->run_qry($qry);
?>

<div id="page-title"><h2>Notification Detail</h2>

    <p>Home / Notification </p></div>
<a href="notification_add_2.php"><button class="btn ra-100 btn-primary">+ Add New<div class="ripple-wrapper"></div></button></a>

<div class="panel">
    <div class="panel-body">
        <div class="example-box-wrapper">
            <table id="datatable-row-highlight" class="table table-striped table-bordered"
                   cellspacing="0" width="100%">
                <thead>
                <tr>
                    <th>Sr No</th>
                    <th>Registration Name</th>
                    <th>Batch Name</th>
                    <th>Blog Name</th>
                    <th>Recipe Name</th>
                    <th>Notification Description</th>
                    <th>Edit</th>
                    <th>Delete</th>
                </tr>
                </thead>
                <?php while($row=mysqli_fetch_array($res)){ ?>
                    <tr>
                        <td><?php echo $i;?></td>
                        <td><?php echo $row['Reg_Name'] ?></td>
                        <td><?php echo $row['BSch_Name'] ?></td>
                        <td><?php echo $row['Blog_Name'] ?></td>
                        <td><?php echo $row['RecName_Name'] ?></td>
                        <td><?php echo $row['Noti_Desc'] ?></td>
                        <td><a href="edit.php?pk=<?php echo $row['id']; ?>">edit</a></td>
                        <td><a href="del_data.php?pk=<?php echo $row['id']; ?>"  onclick="return confirm('Are you sure want to delete  this record?')">delete</a></td>
                    </tr>
                    <?php
                    $i++;
                }
                ?>
                <tbody>
                <?php while($row=mysqli_fetch_array($res)){ ?>
                    <tr>
                        <td><?php echo $i;?></td>
                        <td><?php echo $row['Reg_Name'] ?></td>
                        <td><?php echo $row['BSch_Name'] ?></td>
                        <td><?php echo $row['Blog_Name'] ?></td>
                        <td><?php echo $row['RecName_Name'] ?></td>
                        <td><?php echo $row['Noti_Desc'] ?></td>
                        <td>Edinburgh</td>
                        <td>$320,800</td>
                    </tr>
                    <?php $i++; } ?>
                </tbody>
            </table>
        </div>
    </div>
</div>

<?php
require('footer.php');
?>
</body>
</html>

这是插入数据的地方

<?php
require('header.php');
require('sidebar.php');
include("conn.php");
$con2 = new con_data();

?>

<script type="text/javascript" src="jquery-1.11.0.js"></script>
<script>
    $(document).ready(function () {
        load_data('', 'registration');
        load_data('', 'BSch_Name');
        load_data('', 'blog');
        load_data('', 'RecName_Name');
    });

    function load_data(id, index) {
        //alert('index is ' + index);
        $.ajax({
            url: "db_select.php?index=" + index + "&id=" + id,
            complete: function () {
            },
            success: function (data) {
                $("#" + index).html(data);
                //alert(data);
            }
        })
    }
</script>

<div id="page-title"><h2>Notification Detail</h2>

    <p>Home / Notification</p>
</div>

<div class="panel">
    <div class="panel-body"><h3 class="title-hero"></h3>

        <div class="example-box-wrapper">
            <form method="post" class="form-horizontal bordered-row">

                <div class="form-group"><label class="col-sm-3 control-label">Select registration name</label>

                    <div class="col-sm-6"><select class="form-control" name="registration" id="registration">
                        </select></div>
                </div>

                <div class="form-group"><label class="col-sm-3 control-label">Select batch name</label>

                    <div class="col-sm-6"><select class="form-control" name="BSch_Name" id="BSch_Name">
                        </select></div>
                </div>

                <div class="form-group"><label class="col-sm-3 control-label">Select blog name</label>

                    <div class="col-sm-6"><select class="form-control" name="blog" id="blog">
                        </select></div>
                </div>

                <div class="form-group"><label class="col-sm-3 control-label">Select recipe name</label>

                    <div class="col-sm-6"><select class="form-control" name="RecName_Name" id="RecName_Name">
                        </select></div>
                </div>

                <div class="form-group"><label class="col-sm-3 control-label">Notification Description</label>

                    <div class="col-sm-6"><input type="text" class="form-control" id="Noti_Desc"name="Noti_Desc">
                    </div>
                </div>

                <button type="submit" id="btn_submit" name="btn_submit" class="btn ra-100 btn-primary">Submit<div class="ripple-wrapper"></div></button>
                <button type="submit" id="btn_back" class="btn ra-100 btn-primary"> <- Back<div class="ripple-wrapper"></div></button>
            </form>
        </div>
    </div>
</div>

<?php
if(isset($_POST['btn_submit'])){

    $Noti_Desc = $_POST['Noti_Desc'];
    if($_POST['registration']!='0' && $_POST['BSch_Name']=='0' && $_POST['blog']=='0' && $_POST['RecName_Name']=='0'){

        $qry = "insert into notification(Reg_ID,Noti_Desc) VALUE('" . $_POST['registration'] . "','" . $Noti_Desc . "')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
    if($_POST['BSch_Name']!='0' && $_POST['registration']=='0' && $_POST['blog']=='0' && $_POST['RecName_Name']=='0')
    {
        $qry= "insert into notification(BSch_ID,Noti_Desc) VALUE ('".$_POST['BSch_Name']."','".$Noti_Desc."')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
    if($_POST['blog']!='0' && $_POST['registration']=='0' && $_POST['BSch_Name']=='0' && $_POST['RecName_Name']=='0')
    {
        $qry= "insert into notification(Blog_ID,Noti_Desc) VALUE ('".$_POST['blog']."','".$Noti_Desc."')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
    if($_POST['RecName_Name']!='0' && $_POST['registration']!='0' && $_POST['blog']=='0' && $_POST['BSch_Name']=='0')
    {
        $qry= "insert into notification(RecName_ID,Reg_ID,Noti_Desc) VALUE ('".$_POST['RecName_Name']."','".$_POST['registration']. "','".$Noti_Desc."')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
    if($_POST['RecName_Name']!='0' && $_POST['BSch_Name']!='0' && $_POST['blog']=='0' && $_POST['registration']=='0')
    {
        $qry= "insert into notification(RecName_ID,BSch_ID,Noti_Desc) VALUE ('".$_POST['RecName_Name']."','".$_POST['BSch_Name']. "','".$Noti_Desc."')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
    if($_POST['registration']!='0' && $_POST['BSch_Name']!='0' && $_POST['blog']=='0' && $_POST['RecName_Name']=='0')
    {
        $qry= "insert into notification(Reg_ID,BSch_ID,Noti_Desc) VALUE ('".$_POST['registration']."','".$_POST['BSch_Name']."','".$Noti_Desc."')";
        if($con2->run_qry($qry)){
            echo "<script>";
            echo "window.location='notification.php'";
            echo "</script>";
        }
    }
}

require('footer.php');
?>

请告诉我出了什么问题。

0 个答案:

没有答案