PHP mysql select concat

后端 未结 2 768
遇见更好的自我
遇见更好的自我 2021-01-26 03:43

i have this function that shows an autosuggest in a form:

function searchbyId($params) {

    $input = strtolower($params[\'input\']);
    $len = strlen($input);         


        
2条回答
  •  长情又很酷
    2021-01-26 04:00

    I feel like this is decidedly simple, but you have a syntax error in your concat statement; you're using single quotes to escape strings but the PHP string is defined with single quotes:

    $sql='SELECT DISTINCT nIdentidad, CONCAT(primerNombre, ' ', segundoNombre, ' ', primerApellido, ' ', segundoApellido) AS nombre FROM tarjeta_indent WHERE nIdentidad LIKE \''.$input.'%\' ORDER BY nIdentidad LIMIT '.$limit;
    

    How about this?

    $sql = sprintf(<<

    If I'm right about db_query and you're using Drupal, try this instead (for Drupal 7):

    $sql = << $input, ':limit' => $limit));
    

    This would be the Drupal 6 version:

    $sql = <<

提交回复
热议问题