I am trying to populate a select tag in html form with data from text file. I am using php to do it. Please find the code below:
temp.php
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
$filename = 'C:\templates\exam.txt';
$eachlines = file($filename, FILE_IGNORE_NEW_LINES);
?>
<body>
<div id="page-wrap">
<h1>Pulls from text files</h1>
<select id="value">
<option selected value="base">Please Select</option>
<?php foreach($eachlines as $lines){
echo "<option value='".$lines."'>$lines</option>";
}?>
</select>
</div>
</body>
exam.txt
Req. A + B
Req. B
Req. C
But in the dropdown list I am not getting any data. I am expecting dropdown list to show data from text file as select options.
I am passing php file as render template using Flask. Can we use PHP in Flask?
Can anyone please let me know what I am missing here.
Thanks in advance!
$lines:echo "<option value='".$lines."'>".$lines."</option>";exam.txtwhere the php file is for testing and remove the windows path? Using absolute paths can be a problem. (the\tinC:\templatesmakes me nervous).