Viewing file: resources_list.php (6.74 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?
include ("../include/settings"); include ("../include/db_connect");
/************************************** Do this to add a new category **************************************/
if ($submit == "New category"){ if (strlen($new_category) < 1){ print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"); print("<html>\n"); print("<head>\n"); print("<title>No category entered</title>\n"); print("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"); print("</head>\n"); print("<body>\n"); print("<div align=\"center\" class=\"title\">\n"); print("There is no category name to enter. <br>\n"); print("Please <a href=\"index.php\">go back</a> and enter a category name in the space provided.\n"); print("</div>\n"); print("</body>\n"); print("</html>\n"); } // end of if no category name else{ $query = "INSERT INTO categories (category, active) values ('$new_category', 'yes')"; $entry = mysql_query($query, $db); if ($entry) include ("index.php"); else { print("<p align=\"center\"><br><br><b>OOPS, something went wrong. Try it again.</b><br>If you still have problems, please notify Dan Psomas Web Design<br>by <a href=\"mailto:dan@danpsomas.com?subject=Problems uploading\">e-mail</a> or phone: (510) 865-0273<br>\n<a href=\"index.php\">Go back to admin menu</a>"); } }//end of if category strlen !< 1 }//end of if add category
/********************************************* Do this to select listing for update *********************************************/
else if ($submit == "Update listing"){
$query = "SELECT name, address, city, state, ZIP, ID FROM resources WHERE services = '$modify_category' ORDER BY name"; $data = mysql_query($query, $db); $rows = mysql_num_rows($data);
print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"); print("<html>\n"); print("<head>\n"); print("<title>Select resource to modify</title>\n"); print("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"); print("</head>\n"); print("<body>\n"); print("<table border=\"2\" bordercolor=\"#222244\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"width=\"65%\"><tr><td>\n"); print("<table align=\"center\" border=\"0\"cellpadding=\"0\" cellspacing=\"0\">\n"); if ($rows){
print("\t<tr>\n"); print("\t\t<td align=\"center\" class=\"title\"><br>Please select from the list of $modify_category below to update listing<hr width=\"80%\" size=\"1\" noshade></td>\n"); print("\t\t</tr>\n"); printList($data, $rows); }
else{ print("\t<tr>\n"); print("\t\t<td align=\"center\"><br><hr width=\"80%\" size=\"1\" noshade>Sorry, there are no <b>$modify_category</b> in the database.<br><hr width=\"80%\" size=\"1\" noshade><a href=\"index.php\">Back to Admin index</a><br> </td>\n"); print("\t</tr>\n"); } print("</table>\n"); print("</td></tr></table>\n"); }
/************************************************ Do this to delete a category ************************************************/
else if ($submit == "Delete category!"){ $query = "SELECT name, address, city, state, ZIP, ID FROM resources WHERE services = '$delete_category' ORDER BY name"; $data = mysql_query($query, $db); $rows = mysql_num_rows($data);
print("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n"); print("<html>\n"); print("<head>\n"); print("<title>Select resource to modify</title>\n"); print("<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n"); print("</head>\n"); print("<body>\n"); print("<table border=\"2\" bordercolor=\"#222244\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\"width=\"65%\"><tr><td>\n"); print("<table align=\"center\" border=\"0\"cellpadding=\"0\" cellspacing=\"0\">\n"); if ($rows){ print("\t<tr>\n"); print("\t\t<td align=\"center\"><br><font color=\"Red\"><b>WARNING!</b></font><br>The category <b>$delete_category</b> contains the following entries.<br>\n"); print("\t\tIf you click <i>"Delete the $delete_category category"</i> at the bottom of this page,<br><b>they will be deleted as well</b>.<br>\n"); print("\t\tTo avoid deleting these entries along with the category, you can click on the entry and change its affiliation to another category.\n"); print("\t\t<hr width=\"80%\" size=\"1\" noshade></td>\n"); print("\t</tr>\n"); printList($data, $rows); } else{ print("\t<tr>\n"); print("\t\t<td align=\"center\"><br>The <b>$delete_category</b> category contains no entries. <br>Click on <i>"Delete the $delete_category category"</i> below to delete it.</td>\n"); print("\t</tr>\n"); print("\t<tr>\n"); print("\t\t<td align=\"center\"><br><a href=\"index.php\">Back to Admin index</a><br> </td>\n"); print("\t</tr>\n"); } print("\t<tr>\n"); $urldelete = urlencode($delete_category); print("\t\t<td align=\"center\"><br><hr width=\"80%\" size=\"1\" noshade><a href=\"resources_list.php?delete=yes&category=$urldelete\">Delete the <b>$delete_category</b> category</a><hr width=\"80%\" size=\"1\" noshade><br></td>\n"); print("\t</tr>\n"); print("</table>\n"); print("</td></tr></table>\n");
}//end of if delete category
/************************************************ Part II of delete category (after verification) *************************************************/ else if ($delete == "yes"){ $category = urldecode($category); $category_query = "DELETE FROM categories WHERE category = '$category'"; $delete_category = mysql_query($category_query, $db); $resources_query = "DELETE FROM resources WHERE services = '$category'"; $delete_category = mysql_query($resources_query, $db); if($category_query && $resources_query) include ("index.php"); else{ print("<p align=\"center\"><br><br><b>OOPS, something went wrong. You may need to try it again.</b><br>If you still have problems, please notify Dan Psomas Web Design<br>by <a href=\"mailto:dan@danpsomas.com?subject=Problems uploading\">e-mail</a> or phone: (510) 865-0273<br>\n<a href=\"index.php\">Go back to admin menu</a>"); }
}
/************************************************* F U N C T I O N S *************************************************/
function printList($data, $rows){ if ($rows){ while ($resources = mysql_fetch_array($data)){ print("\t<tr>\n"); print("\t\t<td><br><a href=\"resources_form.php?ID=$resources[ID]\">$resources[name]</a><br>$resources[address]<br>$resources[city]"); print($resources[state] ? ", $resources[state]" : null); print($resources[ZIP] ? " $resources[ZIP]" : null); print("</td>\n"); print("\t</tr>\n"); }//end of while loop print("\t<tr>\n"); print("\t\t<td align=\"center\" class=\"title\"><br><hr width=\"80%\" size=\"1\" noshade><a href=\"index.php\">Back to Admin index</a><br> </td>\n"); print("\t</tr>\n"); }//end of if rows }//end of function
?>
|