Jump to content
Fórum Script Brasil
  • 0

Porobrema Com Rand() No Mysql


MaXiMuS
 Share

Question

2 answers to this question

Recommended Posts

  • 0

to de volta.. bom.. conseguir resolver o problema do RAND()... to usando o código assim agora:

$buscatotal = mysql_query("SELECT * FROM $tab_walls");
$total = mysql_num_rows($buscatotal);
if($total>0) {

function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand(make_seed());
$randval = rand();

for ($i = 0; $i < $nwalls; $i++) {

$wall[$i] = mt_rand(1,$total);
$id_busca = $wall[$i];
$buscawall = mysql_query("SELECT * FROM $tab_walls WHERE id='$id_busca'") or die("ERRO AO SELECIONAR");

    $colunas = "2";
    if (($i%$colunas)==0) {
        echo "</tr>";
        echo "<tr>";
    }
    $dados = mysql_fetch_array($buscawall);
    $id = $dados["id"];
    $thumb = $dados["thumb"];
    echo "<td width=50% align=center><a href='javascript:;' Onclick=\"javascript:abre('walls.php?ID=$id','640','480','0')\"><img border=0 src='$thumb' width=120 height=90></a></td>";
    }



echo "</table>
</center></div>
</td></tr>
</table>
</center></div>";
} else {
    echo "Nenhum registro encontrado";
}
}

dessa veiz postei o código completo.. heheeh.... bom.... ele tá randomizando certinho.. porém tem vez que ele repete o mesmo wall.. fika duas vezes o mesmo... isso tem como corrigir?

Link to comment
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.

 Share



  • Forum Statistics

    • Total Topics
      150.1k
    • Total Posts
      647.1k
×
×
  • Create New...