I am kicking myself in the arse here because i can’t for the life of me figure it out…this is supposed to be a quick and dirty project, but, I decided i want to try something new, and I have little to no experience with the AJAX methods in jQuery…Any help would be more than appreciated, thanks guys!
Again, I am wondering how to go about converting this standard request to AJAX using jQuery…
here is my form & php
HTML:
PHP:
if (isset($_POST)) {
if (!empty($_POST)) {
if ($_GET == 'newCategory') {
$categories = $_POST;
$query = "SELECT * FROM categories WHERE category ='$categories' ";
$result = mysql_query($query) or die(mysql_error());
if (mysql_num_rows($result)) {
echo '';
} else {
// Simply cleans any spaces
$clean = str_replace(' ', '', $categories);
// Makes it possible to add multiple categories delimited by a comma
$array = explode(",", $clean);
foreach ($array as &$newCategory) {
mysql_query("INSERT INTO categories (category) VALUES ('$newCategory')");
}
echo "";
}
}
} else {
echo "";
}
}
?>