Possible Duplicate:
What does the PHP error message “Notice: Use of undefined constant” mean?
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:
(1) Use of undefined constant i - assumed 'i'
(2) Undefined index: i
Does anyone know how to fix this problem?
Here is my code:
<?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;
}
?>