<?php

function GetQuery($q,$valor){
    switch ($q) {
        case 'nombre':
            if ($valor == '-1'){
                return "SELECT first_name FROM authors";                            
            } else {
                return "SELECT first_name FROM authors WHERE id = " . $valor;                            
            }        
            
        case 'apellido':
            if ($valor == '-1'){
                return "SELECT last_name FROM authors";                            
            } else {
                return "SELECT last_name FROM authors WHERE id = " . $valor;                            
            }         
        case 'nombre_completo':
            if ($valor == '-1'){
                return "SELECT first_name,last_name FROM authors";                            
            } else {
                return "SELECT first_name,last_name FROM authors WHERE id = " . $valor;                            
            }               
        case 'autor':
            if ($valor == '-1'){
                return "SELECT * FROM authors";                            
            } else {
                return "SELECT * FROM authors WHERE id = " . $valor;                            
            }                          
    }    
}