Skip to content

Instantly share code, notes, and snippets.

@blooski
blooski / MysqlQuery
Created March 10, 2015 01:26
SUM, TRUNCATE, IFNULL,left join, left outer join, where, group by, limit
$rs = mysql_query("select p.participant_id, stu_first_name, stu_last_name,
SUM(laps_run) as laps,
SUM(TRUNCATE(IFNULL(pledge_amt / maxlaps,0),0)) as pledge,
SUM(IFNULL(amt_collected,0)) collected
from participants as p
left join teachers as t on t.teacher_id = p.teacher_id
left outer join pledges as pl on pl.participant_id = p.participant_id
where pl.teacher_id=$teacher_id
group by p.participant_id
limit $offset,$rows");
@blooski
blooski / ChoosAction
Created April 2, 2015 03:18
Two different form actions depending of radio button
jQuery(document).ready(function($) {
var form = $('form[name="pledgeform"]'),
radio = $('input[name="pledge"]'),
choice = '';
radio.change(function(e) {
choice = this.value;
if (choice === 'yes') {
form.attr('action', 'payment.php');