Hi Sir I will post all the codes so u can undestand it clearly, my goal here is after clicking the submit button is the same page will load with the updated data on it.
<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php find_item(); ?>
<?php
/*if (intval($_GET['inv']) == 0) {
redirect_to('content.php');
}*/
if (isset($_POST['submit'])) {
$errors = array();
// Form Validation
$required_fields = array('item', 'position');
foreach($required_fields as $fieldname) {
if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) {
$errors[] = $fieldname;
}
}
$fields_with_lengths = array('item' => 30);
foreach($fields_with_lengths as $fieldname => $maxlength ) {
if (strlen(trim(mysql_prep($_POST[$fieldname]))) > $maxlength) { $errors[] = $fieldname; }
}
if (empty($errors)) {
// Perform Update
//$id = mysql_prep($_GET['inv']);
$item = mysql_prep($_POST['item']);
$position = mysql_prep($_POST['position']);
/*$query = "UPDATE inventory SET
item = '{$item}',
position = {$position}
WHERE id = {$id}";
$result = mysql_query($query, $connection);
if (mysql_affected_rows() == 1) {
// Success
} else {
// Failed
}
} else {
// Errors occurred*/
}
}// end: if (isset($_POST['submit']))
?>
<?php include("includes/header.php"); ?>
SELECT ITEM:
<?php echo navigation($sel_inventory); ?>
|
Edit Item: <?php echo $sel_inventory['item']; ?>
Item name:
Position:
<?php
$inventory_set = get_inventory();
$inventory_count = mysql_num_rows($inventory_set);
// $subject_count + 1 b/c we are adding a subject
for($count=1; $count <= $inventory_count+1; $count++){
echo "{$count}";
}
?>
<a href="delete_subject.php?subj=<?php echo urlencode($sel_inventory['id']); ?>"
onclick="return confirm('Are you sure?');">Delete Subject</a>
</form>
<br />
<a href="content.php"> Cancel </a>
</td>
</tr>
|
<?php include("includes/footer.php"); ?>