Skip to content

Instantly share code, notes, and snippets.

@Dinamiko
Created October 15, 2015 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dinamiko/6a921525f912ec3661eb to your computer and use it in GitHub Desktop.
Save Dinamiko/6a921525f912ec3661eb to your computer and use it in GitHub Desktop.
<?php
/**
* Devuelve el total de registros donde el campo respuesta es igual valor $respuesta
* @param string $valor respuesta
* @return int $registros total registros
*/
function encuesta_get_registros_respuesta( $respuesta ) {
if( $respuesta ) {
global $wpdb;
$table_name = $wpdb->prefix . "encuesta";
$registros = 0;
$total = $wpdb->get_results( "SELECT * FROM $table_name" );
foreach ( $total as $registro ) {
if( $registro->respuesta == $respuesta ) {
$registros++;
}
}
return $registros;
} else {
return false;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment