dream0776 2018-07-13 09:26
浏览 37

当我点击编辑按钮时,编辑表单中没有显示此错误

I am getting the following error:

http://localhost/sites/admin_panel/student_center_system/controller/admin/editmaster.php?item_id=
Notice: Undefined variable: row in C:\xampp\htdocs\sites\admin_panel\student_center_system\controller\admin\viewitems.php on line 49

when i click edit button on viewitem.php nothing shows up in the form it is empty this viewitems.php The database connection is working perfect but the problem is the edit form .Ihave been stack for two days with this problem about edit form not working.could someone help me please i will appreciate thank you.

enter image description here

   <?php 
        include "navigation.php";
        include "header.php";
        include "footer.php";
    ?> 
    <?php

        include("../dbConfig.php");

        $query = "SELECT item_id,item_name,description,item_category,pic FROM lost_items_table";
        $returnD = mysql_query($query);
        $returnD1 = mysql_query($query);
        $result = mysql_fetch_assoc($returnD);

    ?>

                <!-- Page Content -->
            <div id="page-wrapper">
                <div class="container-fluid">
                    <div class="row">
                        <div class="col-lg-12">
                            <h1 class="page-header">View Items</h1>
                            <div class="row">
                                <div class="col-lg-12">
                                    <div class="panel panel-default">
                                        <div class="panel-heading">View Items</div>
                                        <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                            <tr>
                                                <th>Item Id</th>
                                                <th>Item Name</th>
                                                <th>Description</th>
                                                <th>Item category</th>
                                                <th>Picture</th>
                                                <th>Edit</th>
                                                <th>Delete</th>
                                            </tr>
                                            <?php
                                                while($result1 = mysql_fetch_assoc($returnD1)){
                                                ?>
                                                <tr>
                                                    <td>
                                                        <a href="adminPage.php?activity=itemdetails&item_name=<?php echo $result1['item_name']; ?>"> <?php echo $result1['item_id']; ?> </a>
                                                    </td>
                                                    <td><?php echo ucfirst($result1['item_name']); ?></td>
                                                    <td><?php echo ucfirst($result1['description']); ?></td>
                                                    <td><?php echo ucfirst($result1['item_category']); ?></td>
                                                    <td><?php echo ucfirst($result1['pic']); ?></td>
                                                    <td>    
                                                        <a href="editmaster.php?item_id=<?php echo $row["item_id"]; ?>">Edit</a>
                                                    </td>
                                                    <td>
                                                        <a href="adminPage.php?activity=deleteitem&item_name=<?php echo $result1['item_name']; ?>">Delete</a>
                                                    </td>
                                                </tr>
                                                <?php
                                                }
                                            ?>

                                        </table>
                                        <!-- /.table-responsive -->
                                       </div>
                                    </div>
                                        <!-- /.panel -->
                                </div>
                                    <!-- /.col-lg-12 -->
                            </div>
                        </div>
                        <!-- /.col-lg-12 -->
                    </div>
                    <!-- /.row -->
                </div>
            </div>

this is editmaster.php file.this is the form for editing data and nothing is showing up in the form its empty.what could be wrong with my code .

     <?php session_start();
            include("../dbConfig.php");
            include "navigation.php";
            include "header.php";
            include "footer.php";

        {

        } 
                        $item_id = '';
                        $item_name = '';
                        $description = '';
                        $item_category = '';
                        $pic = '';
                        if (isset($_POST['updateitem']))
                        {

                            if (is_numeric($_POST['item_id']))
                        {

                            $item_id = $_POST['item_id'];
                            $item_name = mysql_real_escape_string(htmlspecialchars($_POST['item_name']));
                            $description = mysql_real_escape_string(htmlspecialchars($_POST['description']));
                            $item_category = mysql_real_escape_string(htmlspecialchars($_POST['item_category']));
                            $pic = mysql_real_escape_string(htmlspecialchars($_POST['pic']));

                        if ($item_name == '' || $description == '' || $item_category == '' || $pic == '')
                        {

                        $error = 'ERROR: Please fill in all required fields!';

                        valid($item_id, $item_name, $description, $item_category, $pic, $error);
                        }
                        else
                        {

                        mysql_query("UPDATE lost_items_table SET item_name = '$item_name', description = '$description', item_category = '$item_category', pic = '$pic' WHERE item_id = '$item_id'")
                        or die(mysql_error());

                        header("Location: viewitems.php");
                        }
                        }
                        else
                        {

                        echo 'Error!';
                        }
                        }
                        else

                        {

                        if (isset($_GET['item_id']) && is_numeric($_GET['item_id']) && $_GET['item_id'] > 0)
                        {

                        $item_id = $_GET['item_id'];
                        $result = mysql_query("SELECT * FROM lost_items_table WHERE item_id=$item_id")
                        or die(mysql_error());
                        $row = mysql_fetch_array($result);

                        if($row)
                        {

                        $item_name = $row['item_name'];
                        $description = $row['description'];
                        $item_category = $row['item_category'];
                        $pic = $row['pic'];

                        valid($item_id, $item_name, $description, $item_category, $pic,'');
                        }
                        else
                        {
                        echo "No results!";
                        }
                        }
                        else

                        {
                        echo 'Error!';
                        }
        }

        ?>



               <!-- Page Content -->
                <div id="page-wrapper">
                    <div class="container-fluid">               
                                        <!-- /.row -->
                                        <div class="row">
                                            <!--div class="col-md-8 col-md-offset-4"-->
                                            <div class="col-lg-6">
                                                <div class="Register-panel panel panel-default">
                                                <!--div class="panel panel-default"-->
                                                    <div class="panel-heading">
                                                        Edit Item
                                                    </div>
                                                    <div class="panel-body">
                                                        <div class="row">
                                                            <div class="col-lg-6">
                                                                <div class="panel-body">
                                                                    <form role="form" action="adminPage.php">
                                                                                <input type="text" name="item_id" value=<?php echo $item_id; ?> readonly><br>
                                                                                <input type="text" name="item_name" required autofocus placeholder="Item-Name" value=<?php echo $item_name; ?>><br>
                                                                                <input type="text" name="description" required autofocus placeholder="Description" value=<?php echo $description; ?>><br>
                                                                                <input type="text" name="item_category" required autofocus placeholder="Item_category" valu
e=<?php echo $item_category; ?>><br>
                                                                                <input type="text" name="pic" required autofocus placeholder="pic" value=<?php echo $pic; ?>><br>

                                                                                <input type="submit" name="updateitemBtn" value="Update">
                                                                    </form>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                    </div>
                </div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测