This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create MySQL connection. Params=(host, DB username, DB passwword, name of Database) | |
$db = mysqli_connect('localhost','username','password','db-name') | |
or die('Error connecting to MySQL server.'); | |
// Create query | |
$query = "SELECT * FROM TABLE"; //Add whatever query desired | |
// Query database using variables | |
mysqli_query($db, $query) or die('Error querying database.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Accept select box id (as string) and return the selected options as an array. | |
* @param {String} selectID HTML id for the select box. | |
*/ | |
function getSelectedOptions(selectID) | |
{ | |
var result = []; | |
var options = document.getElementById(selectID).options; | |
for (var i = 0; i < options.length; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Create a simple javascript array and call the JSON "stringify" method upon it. | |
* Pass the stringified array variable via the URL & GET method and use this line to turn it into a standard PHP array. | |
*/ | |
$array = json_decode(str_replace('\\', '', $_REQUEST['URL-PARAM-NAME'])); | |
// URL-PARAM-NAME = whatever name the JSON string was given when passed via URL (keep single quotes) | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- SCROLLABLE OVERLAY --> | |
<html> | |
<head> | |
<style> | |
.overlay { | |
height: 0%; | |
width: 100%; | |
position: fixed; | |
z-index: 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/** | |
* @author Hei Wah Chan | |
* | |
* | |
* Gist Uploader's Note: This file was created and provided by one of my professors at Franklin University. | |
* These functions provide simple ways to interact with HTML elements (mainly forms) via plain JavaScript. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tableAsCsv(id) { | |
// Make sure table exists and contains at least 1 row | |
if (document.getElementById(id) == null || document.getElementById(id).rows[0] == null) { | |
return; | |
} | |
// Get reference to table & number of rows | |
var tbl = document.getElementById(id); | |
var numRows = tbl.rows.length; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The postAjaxRequest and getAjaxRequst take arguments for a callback function, url, and param string. | |
* Both requests return the response text using "this" inside of the callback function. | |
*/ | |
// POST request | |
function postAjaxRequest(callback, url, args) { | |
var contentType = 'application/x-www-form-urlencoded'; | |
var ajax = new createAjaxObject(callback); | |
if (!ajax) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* PHP utility functions, parameter processing functions, and the renderTemplate functions | |
* Taken from Franklin's WEBD-236 course | |
* Authors: Todd Whittaker & Scott Sharkey | |
*/ | |
function markdown($str) { | |
$str = htmlspecialchars(ltrim($str),ENT_QUOTES); | |
$str = preg_replace('/\*\*(.+)\*\*/u', '<b>$1</b>', $str); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
| Super simple Express server for serving files | |
| Note: Don't forget to npm install express! | |
*/ | |
const express = require('express'); | |
const app = express(); | |
const path = require('path'); | |
/* | |
| Send index file on root visit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This shell script automates the process of creating virtual host config files and enabling sites in Apache | |
# for a localhost. The script requires super user permissions as it creates a config file in the Apache | |
# directory and edits the /etc/hosts file. | |
# | |
# Function: The script will first prompt user to enter a name that will be used for the site and then prompt | |
# for a filepath pointing to the location of the website files (aka DocumentRoot in Apache config). It will | |
# then use these variables to create a config file, enable the site using a2ensite, and then restart Apache. | |
# The script will also append a line to hosts file (ex: 127.0.0.1 site-name.local) to allow access through localhost. |
OlderNewer