inputform中的echo变量

时间:2017-05-07 12:49:01

标签: php mysql edit

在论坛上找到了很多信息。但我坚持到某一点。

我做了什么:

首先我在一个html表中加载mysql数据库并点击执行update.php的行的编辑按钮:

<div class="container-fluid">
     <table id="table_id" class="cell-border order-column row-border hover compact"  width="100%">
        <thead>
            <tr>
            <th width="2%">ID</th>
            <th width="6%">Debiteur</th>
            <th width="10%">Klantnaam</th>
            <th width="3%">Aantal Pallets</th>
            <th width="3%">Totaal Gewicht</th>
            <th width="30%">PB Nummers</th>
            <th width="10%">Toevoegdatum</th>
            <th width="10%">Edit</th>
        </thead>
        <tbody>
            <!-- Fetch from db -->
            <!-- Connect to db-->>
         <?php
        $conn = mysqli_connect("localhost","root","","export") or die("Error in Connection");

        $query = mysqli_query($conn, "SELECT exportid, deb_nmr, cost_name, numb_pal, tot_weight, pb_s, date FROM export_tabel");

        while ($result = mysqli_fetch_array($query)) {
            echo "<tr>
                <td>".$result['exportid']."</td>
                <td>".$result['deb_nmr']."</td>
                <td>".$result['cost_name']."</td>
                <td>".$result['numb_pal']."</td>
                <td>".$result['tot_weight']."</td>
                <td>".$result['pb_s']."</td>
                <td>".$result['date']."</td>
                <td><a href=\"update.php?id=$result[exportid]\"><button type='button' class='btn btn-success btn-xs glyphicon glyphicon-edit'></button></a>
            </tr>";
        }
?>

在update.php中,我尝试在表单中加载选定的表行。这就是我被卡住的地方。

   <?php

// Check connection
if($link === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}


$id=$_GET['id'];
$sql = mysql_query("SELECT exportid, deb_nmr, cost_name, numb_pal, tot_weight, pb_s, date, statusid FROM export_tabel WHERE exportid='$id'");
while ($row = mysql_fetch_array($sql)) {
    $i_d = $row['exportid'];
    $deb = $row['deb_nmr'];
    $name = $row['cost_name'];
    $pal = $row['numb_pal'];
    $weight = $row['tot_weight'];
    $pb = $row['pb_s'];
    $d_ate = $row['date'];
    $status = $row['statusid'];
}
?>

      <form action="updaterow.php" method="post">
         <div class="form-group">
          <label for="email">id:</label>
          <input type="text" class="form-control" name="id" id="id" value="<?php echo $i_d;?>">
        </div>
        <div class="form-group">
          <label for="email">Debiteur:</label>
          <input type="text" class="form-control" name="deb_nmr" id="debiteur" value="<?php echo $deb;?>"/>
        </div>
        <div class="form-group">
          <label for="pwd">Klantnaam:</label>
          <input type="text" class="form-control" name="cost_name" id="costname" value="<?php echo $name;?>"/>
        </div>
        <div class="form-group">
          <label for="pwd">Aantal Pallets:</label>
          <input type="text" class="form-control" name="numb_pal" id="numbpal" value="<?php echo $pal;?>"/>
        </div>
        <div class="form-group">
          <label for="pwd">Totaal gewicht:</label>
          <input type="text" class="form-control" name="tot_weight" id="totweight" value="<?php echo $weight;?>"/>
        </div>
        <div class="form-group">
          <label for="pwd">PB nummers:</label>
          <input type="text" class="form-control" name="pb_s" id="pbs" value="<?php echo $pb;?>"/>
        </div>
           <div class="form-group">
          <label for="email">date:</label>
          <input type="text" class="form-control" name="date" id="date" value="<?php echo $d_ate;?>"/>
        </div>
        <div class="form-group">
          <label for="pwd">statusid:</label>
          <input type="text" class="form-control" name="status" id="status" value="<?php echo $status;?>"/>
        </div>
        <input type="submit" value="update" >
       </form>

我在表单字段中收到以下错误代码:

<br /><b>Notice</b>:  Undefined variable: i_d in <b>/Applications/XAMPP/xamppfiles/htdocs/export/update.php</b> on line <b>31</b><br />

mysql_fetch_array() expects parameter 1 to be resource, object given in /Applications/XAMPP/xamppfiles/htdocs/export/update.php on line 10

希望有人能帮助我朝正确的方向前进:)

0 个答案:

没有答案
相关问题