Ir para conteúdo

Arquivado

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

Bru_ce

Sistema de Sorteio

Recommended Posts

Bom Dia amigos,
Estou desenvolvendo um sistema de sorteio com PHP/MySQL e Ajax.

 

Gostaria de o nome do sorteado aparecer letra por letra de 1 em 1seg.

 

Por exemplo:

 

B ai depois de 1seg R e assim sucessivamente.

 

Alguma sugestão ?


Abs

Compartilhar este post


Link para o post
Compartilhar em outros sites

Bom, eu consegui desta maneira:

 

 

 

PHP
$query = mysql_query("SELECT * FROM tabela WHERE status=0 ORDER BY rand() LIMIT 1");
$linha = mysql_fetch_array($query);
$cont = mysql_num_rows($query);
 
$nome = $linha['nome'];
$id = $linha['id'];
 
 
if($cont ==0 ){
$texto = "";
}
else
{
$texto = "Nome: $nome | Telefone: $id";
$up = mysql_query("UPDATE tabela set status=1 WHERE id=$id");
}
 
?>
 
 
 
HTML
<div id="Fly"><?php echo $texto; ?></div>
 
 
 
JS
<script type="text/javascript">
message = document.getElementById("Fly").innerHTML; // $ = taking a new line
distance = 50;
speed = 250;
 
var txt="",
num=0,
num4=0,
flyofle="",
flyofwi="",
flyofto="",
fly=document.getElementById("Fly");
 
function stfly()
{
   for(i=0;i != message.length;i++)
   {
      if(message.charAt(i) != "$")
         txt += "<span style='position:relative;visibility:hidden;' id='n"+i+"'>"+message.charAt(i)+"<\/span>";
      else
         txt += "<br>";
   }
   fly.innerHTML = txt;
   txt = "";
   fly2b();
}
 
function fly2b()
{
   if(num4 != message.length)
   {
      if(message.charAt(num4) != "$")
      {
         var then = document.getElementById("n" + num4);
         then.style.left = (flyofle - then.offsetLeft + flyofwi / 2) + "px";
         then.style.top = (flyofto - then.offsetTop + distance) + "px";;
         fly3(then.id, parseInt(then.style.left), parseInt(then.style.left) / 5, parseInt(then.style.top), parseInt(then.style.top) / 5);
      }
      num4++;
      setTimeout("fly2b()", speed);
   }
}
 
function fly3(target,lef2,num2,top2,num3)
{
   if((Math.floor(top2) != 0 && Math.floor(top2) != -1) || (Math.floor(lef2) != 0 && Math.floor(lef2) != -1))
   {
      if(lef2 >= 0)
         lef2 -= num2;
      else
         lef2 += num2 * -1;
      if(Math.floor(lef2) != -1)
      {
         document.getElementById(target).style.visibility = "visible";
         document.getElementById(target).style.left = Math.floor(lef2) + "px";
      }
      else
      {
         document.getElementById(target).style.visibility = "visible";
         document.getElementById(target).style.left = Math.floor(lef2 + 1) + "px";
      }
      if(lef2 >= 0)
         top2 -= num3;
      else
         top2 += num3 * -1;
      if(Math.floor(top2) != -1)
         document.getElementById(target).style.top = Math.floor(top2) + "px";
      else
         document.getElementById(target).style.top = Math.floor(top2 + 1) + "px";
 
      setTimeout("fly3('"+target+"',"+lef2+","+num2+","+top2+","+num3+")",50);
   }
}
 
stfly();
</script>

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.