Jump to content
Fórum Script Brasil
  • 0

Frases Aleatórias


lord9999
 Share

Question

Ola pessoal, tenho um site e gostaria de por um sistema de frases aleatorias na index (cada vez que o usuario abrir o site uma frase aleatoria cadastrada em um banco de dados MySQL seria exibida) ...

O codigo que eu estou usando atualmente é o seguinte:

<?

$mydata = "frase";

$myuser = "root";

$myhost = "localhost";

$mypass = "";

$Connect = @mysql_connect($myhost,$myuser,$mypass);

$Select_db = @mysql_select_db($mydata);

?>

<?

/**Selecionanndo os dados do bd */

$sql = "SELECT frase FROM frase WHERE cod > 1";

/** limite exibiccao */

$limite = mysql_query("$sql");

/** exibir tavela mural */

while ($sql = mysql_fetch_array($limite) ) {

$cod = $sql["cod"];

$frase = $sql["frase"];

echo "$frase";

}

?>

Mas Nesse caso o script so exibe a ultima frase cadastrada...

obs: o campo cod esta marcado como "enumerar automatico" no mysql ...

Espero ajuda...

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

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
      151k
    • Total Posts
      649.1k
×
×
  • Create New...