Displaying one record at a time in php
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2941169/what-does-the-php-error-message-notice-use-of-undefined-constant-mean">What does the PHP error message “Notice: Use of undefined constant” mean?</a>  </p>
</blockquote>



<p>I am trying to display one (record) question at a time in the same page. I put a condition at the beginning of the code to check if this is the first time the page loads, if it is, then display the first record. Otherwise, go to the "else" statement where the second record will be displayed. Every time a record is displayed, the counter increases by one ($i++). Also, I saved all the retrieved records in an array and reading the records one at a time from this array.
I don't know why I am getting errors here like the the following:</p>

<blockquote>
  <p>(1) Use of undefined constant i - assumed 'i'</p>
  
  <p>(2) Undefined index: i</p>
</blockquote>

<p>Does anyone know how to fix this problem?</p>

<p>Here is my code:</p>

<pre><code>&lt;?php

 $f_name = $_SESSION['first_name'];
 $l_name = $_SESSION['last_name'];

 $arr_rows;
 $i;

 if (!isset($_POST['next'])) 

 { //if form is not submitted,

  $command2 = "SELECT user_id FROM user_info WHERE user_info.first_name = '$f_name' 
  and user_info.last_name = '$l_name'";

  $command1 = "SELECT * FROM topics, documents WHERE topics.topic_id =documents.topic_id";  

  $i=0; // Counter for the number of documents per topic


  $userid = mysql_query($command2);
  $results = mysql_query($command1);
  $num=mysql_numrows($results);

  //////////////

  $arr_rows = array();
  while( $row = mysql_fetch_array( $results ) )
  $arr_rows[] = $row;


  $arr = mysql_fetch_row($userid);
  $id_user = $arr[0]; 

  echo $f_name;
  $relevancy = "This is the first time to load this page";


  $f1=$arr_rows[i]['topic_name'];
  $f1_topic_description=$arr_rows[i]['topic_descrip'];
  $f1_doc_content=$arr_rows[i]['doc_content'];

  ++$i;

  } 

  else 

  { //otherwise,

    $relevancy = $_POST['RadioGroup1'];

    $f1=$arr_rows[i]['topic_name'];
    $f1_topic_description=$arr_rows[i]['topic_descrip'];
    $f1_doc_content=$arr_rows[i]['doc_content'];

    ++$i;

    }
    ?&gt;
</code></pre>
