The Web Design Resource List

init()) { echo "Well this sucks
\n"; exit; } if ($Delete == "Delete" && !empty($CatID)) { // need to write delete function $sql = "DELETE FROM Categories WHERE CatID=$CatID"; $isdeleted = $db->delete($sql); if ($isdeleted) { print << Category Deleted. EOF; } else { print << There was a problem deleting that category. EOF; } } if ($addcategory == "Add Category") { $CatID = $HTTP_POST_VARS["CatID"]; $CatName = $HTTP_POST_VARS["CatName"]; $CatParent = $HTTP_POST_VARS["CatParent"]; $CatDesc = $HTTP_POST_VARS["CatDesc"]; $CatApproved = $HTTP_POST_VARS["CatApproved"]; $CatSubmitName = $HTTP_POST_VARS["CatSubmitName"]; $CatSubmitEmail = $HTTP_POST_VARS["CatSubmitEmail"]; $CatSubmitDate = $HTTP_POST_VARS["CatSubmitDate"]; if(!empty($CatApproved)) $CatApproved = 1; else $CatApproved = 0; if(empty($CatName)) { return false; } if(empty($CatSubmitName)) { $CatSubmitName = "Anonymous"; } if(empty($CatSubmitEmail)) { $CatSubmitEmail = "Not given"; } $sql = "INSERT INTO Categories "; $sql .= "(CatName,CatParent,CatDesc,CatApproved,CatSubmitName,CatSubmitEmail,CatSubmitDate) "; $sql .= "values "; $sql .= "('$CatName','$CatParent','$CatDesc','$CatApproved','$CatSubmitName','$CatSubmitEmail',$CatSubmitDate) "; $results = $db->insert($sql); if ($results) { print << New Category added. EOF; } else { print << There was a problem adding that category. EOF; } } if ($editlink == "Update Link") { // try to update link here $CatID = $HTTP_POST_VARS["CatID"]; $CatName = $HTTP_POST_VARS["CatName"]; $CatParent = $HTTP_POST_VARS["CatParent"]; $CatDesc = $HTTP_POST_VARS["CatDesc"]; $CatApproved = $HTTP_POST_VARS["CatApproved"]; $CatSubmitName = $HTTP_POST_VARS["CatSubmitName"]; $CatSubmitEmail = $HTTP_POST_VARS["CatSubmitEmail"]; $CatSubmitDate = $HTTP_POST_VARS["CatSubmitDate"]; if(!empty($CatApproved)) $CatApproved = 1; else $CatApproved = 0; if(empty($CatName)) { return false; } if(empty($CatSubmitName)) { $CatSubmitName = "Anonymous"; } if(empty($CatSubmitEmail)) { $CatSubmitEmail = "Not given"; } $sql = "UPDATE Categories SET "; $sql .= "CatID='$CatID',CatName='$CatName',CatApproved='$CatApproved',CatDesc='$CatDesc',CatSubmitName='$CatSubmitName',CatSubmitEmail='$CatSubmitEmail',CatSubmitDate=$CatSubmitDate "; $sql .= "WHERE CatID=$CatID"; $updated = $db->update($sql); if ($updated) { print << Category updated. EOF; } else { print << There was a problem editing that category. EOF; } } ?>

Create a new category
Reload this page

select("SELECT * FROM Categories")); if (empty($record) || $record < 1) $record = 1; $offset = $record - 1; $sql = "SELECT * FROM Categories ORDER BY CatSubmitDate DESC LIMIT $offset,$max_per_page"; $results = $db->select($sql); $records_this_page = count($results); $this_page_first = $record; $this_page_last = $record + $records_this_page - 1; $next_page_first = $this_page_last + 1; $prev_page_first = $this_page_first - $max_per_page; if(!empty($results)) { print "

\n"; print "Categories: (showing $this_page_first-$this_page_last of $total)\n"; print "

\n"; if ($records_this_page < $total) { print "

\n"; // print previous category if required if ($this_page_first > 1) print "previous "; // print numbered categories to remaining pages for ($i=1;$i<=ceil($total/$max_per_page);$i++) { if ($record > ($i-1)*$max_per_page && $record <= $i*$max_per_page) { print "$i "; } else { $next = ($i-1)*$max_per_page+1; print "$i "; } } // print next category if required if ($this_page_last < $total) print "next"; print "

\n"; } print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; $isodd = TRUE; while ( list ( $key,$val ) = each ($results)) { $CatID = stripslashes($val["CatID"]); $CatName = stripslashes($val["CatName"]); $CatParent = stripslashes($val["CatParent"]); $CatDesc = stripslashes($val["CatDesc"]); $CatSubmitDate = stripslashes($val["CatSubmitDate"]); $FormattedDate = date("d/m/y",$CatSubmitDate); if ($isodd) { $rowclass = "odd"; $isodd = FALSE; } else { $rowclass = "even"; $isodd = TRUE; } $CatParentName = $db->get_CatNames($CatParent); print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; } print "
NameParentDateOptions
$CatName$CatParentName$FormattedDatevisiteditdelete
\n"; if ($records_this_page < $total) { print "

\n"; // print previous link if required if ($this_page_first > 1) print "previous "; // print numbered links to remaining pages for ($i=1;$i<=ceil($total/$max_per_page);$i++) { if ($record > ($i-1)*$max_per_page && $record <= $i*$max_per_page) { print "$i "; } else { $next = ($i-1)*$max_per_page+1; print "$i "; } } // print next link if required if ($this_page_last < $total) print "next"; print "

\n"; } } else { print "No matches!"; } ?>