<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: JeevaSaravanan</title>
    <description>The latest articles on DEV Community by JeevaSaravanan (@jeevasaravanan).</description>
    <link>https://dev.to/jeevasaravanan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F287703%2F19f7c5cf-7cea-4bee-9885-16102567598d.png</url>
      <title>DEV Community: JeevaSaravanan</title>
      <link>https://dev.to/jeevasaravanan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeevasaravanan"/>
    <language>en</language>
    <item>
      <title>Display records from Database one at a time</title>
      <dc:creator>JeevaSaravanan</dc:creator>
      <pubDate>Sun, 08 Dec 2019 11:18:33 +0000</pubDate>
      <link>https://dev.to/jeevasaravanan/display-records-from-database-one-at-a-time-2k1o</link>
      <guid>https://dev.to/jeevasaravanan/display-records-from-database-one-at-a-time-2k1o</guid>
      <description>&lt;p&gt;Can anyone tell me how to retrieve records from database one at a time.&lt;/p&gt;

&lt;p&gt;I am attaching my code here:&lt;/p&gt;

&lt;p&gt;Let me explain the code..&lt;/p&gt;

&lt;p&gt;The database I am using is MariaDB.&lt;/p&gt;

&lt;p&gt;There is a table named "cquest" (containing some questions) in database with a field named "question" and options are in field "opt1,opt2,opt3,opt4".&lt;/p&gt;

&lt;p&gt;The below code display all the questions stored in the table into the screen.&lt;/p&gt;

&lt;p&gt;My problem is here: I want to display the questions one by one. Like when we click the next button it will display the next question and so until all the records are displayed.&lt;/p&gt;

&lt;p&gt;Help me out with the main logic I should use to implement it. Or help me with the script.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;       $servername = "localhost";
       $username = "root";
       $password = "";
       $dbname = "quiz";
       $conn = new mysqli($servername, $username, $password, $dbname);
       if ($conn-&amp;gt;connect_error) {
        die("Connection failed: " . $conn-&amp;gt;connect_error);
        }

       $sql = "SELECT * FROM cquest";
       $result = $conn-&amp;gt;query($sql);
       if ($result-&amp;gt;num_rows &amp;gt; 0) {
        while($row = $result-&amp;gt;fetch_assoc()) {
          echo "&amp;lt;div class='row'&amp;gt;";
            echo "&amp;lt;div class='col-md-6 mb-6'&amp;gt;";
            echo "&amp;lt;div class='card shadow border-0 h-100'&amp;gt;";
            echo "&amp;lt;div class='card-body'&amp;gt;";
            echo "&amp;lt;h5 class='dark-text'&amp;gt;".$row['question']."&amp;lt;/h5&amp;gt;";
            echo "&amp;lt;div class='bg-light'&amp;gt;";
            echo "&amp;lt;code class='dark-text'&amp;gt;".$row['ccode']."&amp;lt;/code&amp;gt;";
          echo "&amp;lt;/div&amp;gt;";
            echo "&amp;lt;div class='custom-control custom-radio'&amp;gt;";
                  echo "&amp;lt;input type='radio' class='custom-control-input' id='defaultGroupExample1'  name='ans' value='a' checked&amp;gt;";
                  echo "&amp;lt;label class='custom-control-label' for=defaultGroupExample1&amp;gt;".$row["opt1"]."&amp;lt;/label&amp;gt;&amp;lt;/br&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;div class='custom-control custom-radio'&amp;gt;";
                  echo "&amp;lt;input type='radio' class='custom-control-input' id='defaultGroupExample2'  name='ans' value='b'&amp;gt;";
                  echo "&amp;lt;label class='custom-control-label' for=defaultGroupExample2&amp;gt;".$row["opt2"]."&amp;lt;/label&amp;gt;&amp;lt;/br&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;div class='custom-control custom-radio'&amp;gt;";
                  echo "&amp;lt;input type='radio' class='custom-control-input' id='defaultGroupExample3'  name='ans' value='c'&amp;gt;";
                  echo "&amp;lt;label class='custom-control-label' for=defaultGroupExample3&amp;gt;".$row["opt3"]."&amp;lt;/label&amp;gt;&amp;lt;/br&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;div class='custom-control custom-radio'&amp;gt;";
                  echo "&amp;lt;input  type='radio' class='custom-control-input' id='defaultGroupExample4' name='ans' value='d'&amp;gt;";
                  echo "&amp;lt;label class='custom-control-label' for=defaultGroupExample4&amp;gt;".$row["opt4"]."&amp;lt;/label&amp;gt;&amp;lt;/br&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;button name=submit class=next&amp;gt;NEXT&amp;lt;/button&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";
                  echo "&amp;lt;/div&amp;gt;";

        }
        }
       }
       else {
        echo "Currently Unavailable";
       }
        $conn-&amp;gt;close(); 
       ?&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

</description>
      <category>php</category>
      <category>javascript</category>
      <category>sql</category>
    </item>
  </channel>
</rss>
