• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Why is my page not updating immediately?

Hi, I have a page where one can remove categories:

(HOWEVER please do not remove any of the first three categories, as they have info that I need!)

http://www.auroriella.com/remove.php

When I remove a category it removes it but it does not show that its removed till I refresh the page.  It just bolds the category. . . this is really frustrating because on the opposite side of things in the create category page:

http://auroriella.com/new_category.php

it shows the update immediately!!  Can anyone figure this out??

Create Category
// If there were no errors and the sumbit button was clicked data is inserted into the database
function insert_fields() {
	global $conn, $message, $errors, $error;
	if((empty($errors)) && (isset($_POST['submit']))) { // Perform Add
		$name = mysql_clean_strings($_POST['name']);

		// Send data to the database 
		$adjust = "ALTER TABLE products AUTO_INCREMENT = 1";
		$query = "INSERT INTO products (menu_id, name, visible) VALUES (
				 '1',
				 '$name',
				 '1');";
		$noGaps = mysql_query($adjust, $conn);
		$result = mysql_query($query, $conn);
		confirm_query($result);
		if ($result) {
			// Successful
			$message = "The category was successfuly created.";
		}
		else {
			// Failed
			$error = "The category creation failed.";
			$error .= "<br />" . mysql_error();
		}
	}
}

Open in new window


Delete Category:
function delete() {
	if((empty($errors)) && (isset($_POST['submit']))) { // Perform Delete
		global $conn, $message, $error;
		$name = mysql_clean_strings($_POST['table']);
		$query = "DELETE FROM products WHERE name='" . $name . "' LIMIT 1";
		$result = mysql_query($query, $conn);
		if($result) {
			$message = "Product was successfully deleted.";
		}
		else {
			// Deletion Falied
			$error = "<p>Category deletion failed.</p>";
			$error .= "<p>" . mysql_error() . "</p>";
		}
	}
	else {
		//Product didn't exist in the database
		$error = "<p>Category did not exist in the database.</p>";
	}
}

Open in new window


http://auroriella.com/new_category.txt

http://auroriella.com/remove.txt
0
FairyBusiness
Asked:
FairyBusiness
  • 4
  • 3
  • 2
1 Solution
 
Marco GasiFreelancerCommented:
The problem resides in the fact you create dinamically the select with the code

 <label>Category Name: <?php echo table() ?></label>

Here I suppose that in table() you iloop the database to retrieve correct values. The left side menu is static instead: you have to create it dinamically the same way you create the select.

Hope this helps.

Cheers
0
 
FairyBusinessAuthor Commented:
But the left side menu is created with a loop too pulling categories from the database.  That why when you add a new category it shows immediately!
0
 
Marco GasiFreelancerCommented:
You're right: I've been too optimist! Looking at your pages, the only difference I can see is the javascript alert to ask a confirmation to delete category: I think we have to analyze how this code is implemented.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
FairyBusinessAuthor Commented:
I got rid of the jquery alert but no improvement.  I'm not sure what else to analyze. ..
0
 
Marco GasiFreelancerCommented:
Hmmm... It's really ununderstandable! Now I have to go, but if you could get rid of the jquery alert and let us test the page without it... I don't see any other difference... See you later.
0
 
FairyBusinessAuthor Commented:
Ok, I got rid of it
0
 
hieloCommented:
make sure you delete() the selected item BEFORE you create the left side of the page.
0
 
FairyBusinessAuthor Commented:
Yep, right again  :)  I'm always so happy when you comment on my questions
0
 
hieloCommented:
ex:

<?php
ini_set('display_errors' ,1);
error_reporting(E_ALL);

require_once 'includes/library.php';
$title = "Auroriella Management";

delete();

include 'header.php';

//confirm_login(); // Checks to see if user is still logged always
validate_fields(); // Validation
find_selected_id(); // Needs to go below update_fields to show updates

echo edit_nav($select_nav);

include 'sidebar.php';
echo edit_menu($select_menu, $select_product, $select_metal);

include 'manage.php';
echo output();
?>
<h3>+ Delete A Category</h3>
<form action="remove.php" method="post">
 <label>Category Name: <?php echo table() ?></label>
 <!--<a href="" id="sub">+ Add A Sub Category</a>
 <div class="sub_categories">
 <label><?php echo metals() ?></label>
 <label>Collection Name: <input type="text" name="collection" id="name" value="" /></label>
 <br style="clear: both" />
 </div>-->
 <input type="submit" name="submit" id="delete" value="Delete Category" />
</form>
<?php
require 'footer.php';
?>
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now