I have a php page which is reading a text file and printing the file line by line. and also I have given 'yes' 'no' option with every line.Now I want to print those lines in the 2nd page which is selected as yes.If user select yes then I want to print those line to next page.I have the below code.Can any one check this code?
<?php
$i=0;
$lines = file("text.txt");
foreach($lines as $line) {
$select_val=$line.'-'.$i;
print " <br> ";
print " <br> ";
echo($line);
echo '<select name=".$select_val.">';
echo '<option value="Yes">Yes</option>';
echo '<option value="No">No</option>';
echo '</select>';
print " <br> ";
print " <br> ";
$i++;
}
?>
<input type="hidden" name="ival" value="$i" /> <?
print "<input type=submit value=Submit><input type=reset>";
?>
2nd page:
<?php
$i=0;
$lines = file("text.txt");
foreach($lines as $line) {
$select_val=$line.'-'.$i;
$a=$_POST[$select_val];
if ($a == 'Yes') {
echo($line);
}
$i++;
}
?>