mercredi 18 janvier 2017

Generate multiple random sentences instead of one using php mysql

Hi friends am trying to generate multiple random sentences instead of 1.Here is my code..

<div id="content" >
    <?php 
    $result = mysql_query('SELECT * FROM Questions ORDER BY RAND() LIMIT 2');
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }


    while ($row = mysql_fetch_array($result)) {
        echo $row['facts'].'&nbsp';
    }
    ?>
</div>

My database table name is questions and my column name is facts.Here is my pattern

  facts
  ramu
  somesh
  kumar
  getup  

Right now am getting output as

    ramu getup

How can I get multiple sentences when page is refreshed only once like below without duplicate sentences

      ramu getup
     somesh ramu
     kumar somesh

Thanks




Aucun commentaire:

Enregistrer un commentaire