Skip to content

Instantly share code, notes, and snippets.

View edavis25's full-sized avatar

Eric Davis edavis25

View GitHub Profile
@edavis25
edavis25 / getSelectOptions.js
Created November 3, 2016 23:32
Javascript function for retrieving values from HTML select/option input.
/*
* 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++)
@edavis25
edavis25 / database-query.php
Last active November 4, 2016 00:49
PHP Database Connection
<?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.');