Found much information on the forum. But im stuck at a certain point.
What did i do:
First i load mysql database in a html table and hit the edit button of a row which executes 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>";
}
?>
In update.php i try to load the selected table row in a form. This is where i get stuck.
<?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>
i am getting the following error code in the form fields:
<br /><b>Notice</b>: Undefined variable: i_d in <b>/Applications/XAMPP/xamppfiles/htdocs/export/update.php</b> on line <b>31</b><br />
and
mysql_fetch_array() expects parameter 1 to be resource, object given in /Applications/XAMPP/xamppfiles/htdocs/export/update.php on line 10
Hope somebody can help me in the right direction:)