Username:   Password:  

Order MySQL result by occurence of a field

SELECT
 `row`,
 COUNT(row) AS `count`,
FROM
 `table`
GROUP BY
 `row`
ORDER BY
 `count`;
 
 

Sometimes it is necessary, to sort the rows of a MySQL select statement by the occurence of a field value.

Tags

MySQL count database select order occurences

Getting the value of multiple selected options

var foo = [];  
$('#multiple :selected').each(function(i, selected){
  foo[i] = $(selected).text();
});
// to get the selected values, just use .val() - this returns a string or array
foo = $('#multiple :selected').val();  

We’re using jQuery’s “each()” method to loop through all selected options in a multiple select list. Each value or text value is read into an array for later use.

Tags

jQuery javascript input select form