Skip to content

Instantly share code, notes, and snippets.

David Patrick McKenzie dpmckenzie

View GitHub Profile
@dpmckenzie
dpmckenzie / open_db.php
Created Oct 20, 2012
File for opening a database
View open_db.php
<?php
$mysqli = new mysqli('[address of database]', '[username]', '[password]', '[database name]');
// check connection
if (mysqli_connect_errno()) {
exit('Connect failed: '. mysqli_connect_error());
}
?>
@dpmckenzie
dpmckenzie / records.php
Created Oct 4, 2012
Where I am so far in my CRUD form...
View records.php
<?php
/*
Allows the user to both create new records and edit existing records
*/
// connect to the database
include("open_db.php");
// creates the new/edit record form
// since this form is used multiple times in this file, I have made it a function that is easily reusable
@dpmckenzie
dpmckenzie / listing.php
Created Oct 4, 2012
Listing page, with still non-functional links to edit
View listing.php
<html>
<head>
<title>U.S. Citizen Claims Against Mexico to 1846: Case Listing</title>
</head>
<body>
<?php include("open_db.php");
echo "<h1>U.S. Citizen Claims Against Mexico to 1846: Listing</h1>
<p>Below you will find the listing of claims against Mexico, date in which the claims were filed, and total amounts of the initial claim and final verdict. You can click to edit the claims, or to add new ones--or at least will be able to, once I figure out the whole forms thing.</p>";
@dpmckenzie
dpmckenzie / query.php
Created Oct 4, 2012
My query page so far, where I define the queries. Next step: having the user define the queries.
View query.php
<html>
<head>
<title>U.S. Citizen Claims Against Mexico to 1846: Case Listing</title>
</head>
<body>
<?php include("open_db.php");
echo "<h1>U.S. Citizen Claims Against Mexico to 1846: Listing</h1>
<p>Below you will find the listing of claims against Mexico, date in which the claims were filed, and total amounts of the initial claim and final verdict. You can click to edit the claims, or to add new ones--or at least will be able to, once I figure out the whole forms thing.</p>";
@dpmckenzie
dpmckenzie / database_list.php
Created Sep 27, 2012
Wordpress page template for creating a simple listing of my database contents. Note that I have redacted my login info.
View database_list.php
<?php
/**
* Template Name: Custom database tables
* @package WordPress
* @subpackage Coraline
* @since Coraline 1.0
*/
coraline_set_full_content_width();
get_header(); ?>
@dpmckenzie
dpmckenzie / Full-column_page.php
Created Sep 27, 2012
This is the regular full-column page from Wordpress's Coraline theme (which I use). I've made slight alterations (below) to get rid of the title and comments for my homepage.
View Full-column_page.php
<?php
/**
* Template Name: Full-width, no sidebar
* @package WordPress
* @subpackage Coraline
* @since Coraline 1.0
*/
coraline_set_full_content_width();
get_header(); ?>
@dpmckenzie
dpmckenzie / csv_manipulate.php
Created Sep 24, 2012
My not-quite-functioning CSV-modifying PHP file--not functioning even after class help. If anyone has ideas, do tell. I meanwhile have learned a faster way to do this. :)
View csv_manipulate.php
<?php
ini_set("auto_detect_line_endings", true);
$fileName = 'cases.csv';
// set function for opening file
$file = fopen($fileName, "r+") or die("can't open file");
// recognize file as csv, get it to loop
while(($data = fgetcsv($file, 1000, ',')) !== FALSE) {
You can’t perform that action at this time.