• 0
Sign in to follow this  
Guest Dan Dao

Rand

Question

Guest Dan Dao

Olá, gostaria q alguém pudesse me ajudar....estou tentando colocar um rand nos resultados do meu bd...mas n estou conseguindo..alguém poderia colocar e arrumar o codigo pra mim? ta ai o codigo e onde eu quero q da o rand ta em forma de comentario....obrigado

$query_teste = "SELECT * FROM catalago_empresas where pago='S' and tipo='A'"; 
$teste1 = mysql_query($query_teste, $teste) or die(mysql_error()); 

//calculo da quantidade de linhas e colunas
if(!(mysql_num_rows($query_teste)==0))
{
// rand nos resultados
}
  else
{
//
} 
$row_teste1 = mysql_fetch_assoc($teste1); 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

olá amigo.. coloque assim no final de sua query

ORDER BY rand()

wink.gif

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this