title: PHP code to fetch random data from database with link
body: <p>I have a project from my college. I need to make a site which will generate random data from database. But it will also need to generate a link. So that people can copy that link (as the website is generating different data, people can see the data they want by copying the URL).</p>
  
  <p>I was thinking to use RAND(). But after joining stackoverlow, I see that RAND() is not a good way. </p>
  
  <p>I can fetch random data using RAND() but it is not making any URL. Which is another problem too. I post this problem before. I think I shouldn't use the RAND() function.</p>
  
  <p>this is the code I'm using at this moment:</p>
  
  <pre><code>&lt;!--PHP code for fetching data from database--&gt;
  &lt;?php
    $con = mysql_connect("localhost","root","");
    if (!$con){
    die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("xlsx_db", $con);
  
    $result = mysql_query("SELECT * FROM sheet1 ORDER BY RAND() LIMIT 1");
  
    if (!$result) {
    echo 'Could not run query: ' . mysql_error();
    exit;
    }
  
    $row = mysql_fetch_array($result);
    echo "&lt;b&gt;Quote: &lt;/b&gt;";
    echo $row['quote']."&lt;br&gt;";
    echo $row['by']."&lt;br&gt;";
  ?&gt;
  </code></pre>
  
  <p>Anyone could please suggest me how to do that? Any kind of help will be very much appreciated.</p>