Skip to content

Instantly share code, notes, and snippets.

View dpmckenzie's full-sized avatar

David Patrick McKenzie dpmckenzie

View GitHub Profile
@dpmckenzie
dpmckenzie / open_db.php
Created October 20, 2012 17:41
File for opening a database
<?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 October 4, 2012 03:27
Where I am so far in my CRUD form...
<?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 October 4, 2012 03:16
Listing page, with still non-functional links to edit
<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 October 4, 2012 03:05
My query page so far, where I define the queries. Next step: having the user define the queries.
<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 September 27, 2012 04:25
Wordpress page template for creating a simple listing of my database contents. Note that I have redacted my login info.
<?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 September 27, 2012 04:21
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.
<?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 September 24, 2012 04:00
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. :)
<?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) {