i have a problem concerning a editing a field in a table
every time i click on the edit button ut gives me the edit page but with the same Field over and over!
this is the 2pages:
<?php
include_once('core.php');
$conn = connect();
$result = mysqli_query($conn, "select * from cartable");
$fields = mysqli_fetch_fields($result);
?>
<div align="center">
<table border="1" cellpadding="3" cellspacing="2">
<tr>
<?php for($i=1; $i<count($fields); $i++) : ?>
<th><?php echo $fields[$i]->name ?></th>
<?php endfor; ?>
<th>Edit Car</th>
</tr>
<?php while($record = mysqli_fetch_array($result, MYSQLI_NUM)) : ?>
<tr>
<?php for($i=1; $i< count($record); $i++) : ?>
<td><?php echo $record[$i] ?></td>
<?php endfor; ?>
<td><a href="edit.php?id=<?php echo $record[0] ?>">Edit Car</a></td>
</tr>
<?php endwhile; ?>
</table>
</div>
and the other file:
<?php
//connect to database server and select a database called cars
$conn = mysqli_connect("localhost", "root", "", "cars");
//execute an sql stm using the connection called $conn
$result = mysqli_query($conn, "select * from cartable where id=2");
$record = mysqli_fetch_array($result, MYSQLI_ASSOC);
$fields = mysqli_fetch_fields($result);
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post">
<?php foreach($fields as $field) : ?>
<label for="<?php echo $field->name ?>"><?php echo $field->name ?></label>
<input type ="text" name="<?php echo $field->name ?>" id="<?php echo $field->name ?>" value="<?php echo $record[$field->name] ?>" />
<br />
<?php endforeach; ?>
<input type="submit" />
</form>