Random Snippets

  • Home
  • Sequence analysis blog
  • About
  • Categories
    • javascript
    • mysql
    • php
  • Subscribe via RSS

How to count values with MySQL queries

October 5th, 2008  |  by Knix  |  published in mysql

Let’s say you have the following table called votes that keeps track of how people voted and you want a query to count the number of votes for you instead of having to loop through all the rows with a counter in PHP.

person
vote

obama
yes

mccain
no

obama
yes

obama
no

mccain
yes

obama
yes

obama
yes

obama
no

mccain
no

How to loop through checkboxes or radio button groups via JavaScript

May 15th, 2008  |  by Knix  |  published in javascript

function loopForm(form) {
var cbResults = ‘Checkboxes: ‘;
var radioResults = ‘Radio buttons: ‘;
for (var i = 0; i < form.elements.length; i++ ) {
if (form.elements[i].type == ‘checkbox’) {
[...]

Recent Posts

  • Sorting 2D associative arrays in PHP
  • About
  • Dynamic or on-the-fly percentage calculations with JavaScript
  • Sequence analysis blog
  • The dangers of embedding the notorious “void(0)” JavaScript code in the href attribute of the “a” tag

Recent Comments

  • drei on Simulate a button click via JavaScript
  • Subhee on How to count values with MySQL queries
  • Russell Day on How to hide, show, or toggle your div
  • phi on How to hide, show, or toggle your div
  • bornholy on How to hide, show, or toggle your div

Archives

Categories

  • javascript
  • mysql
  • php

Tag Cloud

add addition and subtraction calculator checkboxes checkEmail content demo demo content div id document getelementbyid dynamic Dynamically dynamic content emailRegEx find form getElementById html javascript input buttons input object input text javascript javascript code javascript demo javascript email javascript function javascript functions loop through menu multiplication mysql mysql query onClick onclick event query regex remove removeChild removeElement replace simulate styling valid email address verification verifyEmail


©2010 Random Snippets