Ver Mensaje Individual
  #1 (permalink)  
Antiguo 20/02/2014, 11:15
Karen_mBrK
 
Fecha de Ingreso: enero-2014
Mensajes: 127
Antigüedad: 10 años, 3 meses
Puntos: 2
problemas con select.

Hola, espero y puedan ayudarme, presiento que es un problema muy sencillo, pero no logro resolverlo.

Necesito hacer un select, que me traiga la información de usuarios respecto a la búsqueda, pero solamente si su nivel de permiso es la indicada.

Aquí el código completo

Código PHP:
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}

$maxRows_Recordset1 10;
$pageNum_Recordset1 0;
if (isset(
$_GET['pageNum_Recordset1'])) {
  
$pageNum_Recordset1 $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 $pageNum_Recordset1 $maxRows_Recordset1;

$colname_Recordset1 "-1";
if (isset(
$_POST['buscar'])) {
  
$colname_Recordset1 $_POST['buscar'];
}
mysql_select_db($database_Pharma$Pharma);
$query_Recordset1 sprintf("SELECT * FROM usuarios, login ON  usuarios.curp = login.curp WHERE Apellido_P LIKE %s AND login.Nivel = 'SUPERVISOR,USER'"GetSQLValueString("%" $colname_Recordset1 "%""text"));
$query_limit_Recordset1 sprintf("%s LIMIT %d, %d"$query_Recordset1$startRow_Recordset1$maxRows_Recordset1);
$Recordset1 mysql_query($query_limit_Recordset1$Pharma) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);

if (isset(
$_GET['totalRows_Recordset1'])) {
  
$totalRows_Recordset1 $_GET['totalRows_Recordset1'];
} else {
  
$all_Recordset1 mysql_query($query_Recordset1);
  
$totalRows_Recordset1 mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
O aquí, solo la parte del select:

Código PHP:
SELECT FROM usuarioslogin 
ON  usuarios
.curp login.curp 
WHERE Apellido_P LIKE 
%AND login.Nivel 'SUPERVISOR,USER' 
Pero al hacerlo así, me da este error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON usuarios.curp = login.curp WHERE Apellido_P LIKE '%-1%' AND login.Nivel = 'S' at line 1

Intenté reemplazarlo por el siguiente código, y aunque no me marca ningún error, tampoco me trae resultados:

Código PHP:
SELECT *
FROM usuarioslogin
WHERE usuarios
.curp login.curp AND login.Nivel 'SUPERVISOR,USER' and  Apellido_P LIKE %colname
Gracias.

Última edición por Karen_mBrK; 20/02/2014 a las 11:21