Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

MARCOSOFTHARD

LIMIT na consulta sql

Recommended Posts

Ola pessoal, tenho uma consulta que mostra um determinado dados via WHERE e esta ORDER BY art.nome ASC

 

Mais na hora que especificar um limit não funciona, o que acontece é que o limit não obedece o WHERE.

 

$inicio = $_GET["inicio"];
$total = 15;
if ($inicio == "")
{
$inicio = 0;
}

			$result = mysql_query("select id, nome from artistas AS art where art.id ORDER BY art.nome ASC LIMIT $inicio, $total") or die(mysql_error());
				while($artistas = mysql_fetch_array($result))

Compartilhar este post


Link para o post
Compartilhar em outros sites

Coloquei assim e deu erro, depois removi o where pq ele não tinha where ali.

 

$result = mysql_query("select id, nome from artistas LIMIT $inicio, $total AS art ORDER BY art.nome ASC ") or die(mysql_error());
				while($artistas = mysql_fetch_array($result))

 

 

 

 

Esse é o código original do site

 

 

 

 

 

 

 

 

$categoria = $_GET['categoria'];
$busca = mysql_query("select grupos.* from grupos, musicas where musicas.grupo = grupos.id AND grupos.id = $categoria group by grupos.id ORDER BY grupos.nome ASC");
while ($array = mysql_fetch_array($busca))
	{
	$nome_cat = $array['nome'];
	$categoria = $array['id'];
?>
						  <table width="354" cellpadding="10" cellspacing="0" bgcolor="#a0033e" class="borda">
							<tbody>
							  <tr>
						<td class="txt-titulo-cinza"><?=$nome_cat?></td>
					</tr>
				  </tbody></table>
<?
$inicio = $_GET["inicio"];
$total = 15;
if ($inicio == "")
{
$inicio = 0;
}


			$result = mysql_query("select id, nome from artistas AS art where art.id ORDER BY art.nome ASC LIMIT $inicio, $total") or die(mysql_error());
				while($artistas = mysql_fetch_array($result))

Compartilhar este post


Link para o post
Compartilhar em outros sites

coloca o LIMIT do final da QUERY...

$result = mysql_query("select id, nome from artistas, $total AS art ORDER BY art.nome ASC LIMIT $inicio") or die(mysql_error());

Compartilhar este post


Link para o post
Compartilhar em outros sites

Fiz mais deu o seguinte erro

 

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 '15 AS art ORDER BY art.nome ASC LIMIT 0' at line 1

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.