I am trying to populate one table in PHP reading data from one file and parsing data line by line. In one table field, I want the field should show some drop-down select list items which are constant- not dynamically generated, so that when the user selects one item from the drop-down list and clicks on the save button, it should select that row's data and pass it to some script as arguments to execute in the backend.
I am able to set the required table data as editable, but not able to make it as a drop-down list of defined values.
echo "<br><table border=0 style='width:100%;'><tr bgcolor=#333333 align=center> <td><font face=verdana size=2 color=#ffffff>Name</td> <td><font face=verdana size=2 color=#ffffff>Id</td> <td><font face=verdana size=2 color=#ffffff>Project </td> <td><font face=verdana size=2 color=#ffffff>IP Address</td> <td><font face=verdana size=2 color=#ffffff>Severity</td> <td><font face=verdana size=2 color=#ffffff>Memory</td> <td><font face=verdana size=2 color=#ffffff>details1</td> <td><font face=verdana size=2 color=#ffffff>details2</td> <td><font face=verdana size=2 color=#ffffff>details3</td> <td><font face=verdana size=2 color=#ffffff>details4</td> <td><font face=verdana size=2 color=#ffffff>details5</td> </tr>\n";
if (($handle = fopen("$filepath$name", "r")) !== FALSE)
{
while (($data = fgetcsv($handle, 10000, ",")) !== FALSE)
{
echo "<tr bgcolor=#eeeeee>";
for ($line=0;$line<count($data);$line++)
{
echo "<td align='center' font face=verdana size=2 color=#000000 >".$data[$line + 5]."</td>"; //Name
echo "<td align='center' font face=verdana size=2 color=#000000 >".$data[$line + 0]."</td>"; //Id
echo "<td align='center' font face=verdana size=2 color=#000000 >".$data[$line + 1]."</td>"; //Project
echo "<td align='center' font face=verdana size=2 color=#000000 >".$data[$line + 8]."</td>"; //IP addr
echo "<td align='center' font face=verdana size=2 color=#66ff66 contenteditable='true'></td>"; //Severity
echo "<td align='center' font face=verdana size=2 color=#000000 >".$data[$line + 3].$MB."</td>"; //Memory
...
...
}
echo "</tr>";
}
fclose($handle);
}
echo "</table>";
I want the 5th <td>
tag should provide some drop-down options like P1, P2, P3, and Default so that when the user selects one and click save button the script should pass that entire row data from the table to some script as arguments to execute some action. Currently, the 5th <td>
field is showing as an editable field (contenteditable='true'
) with empty content.
Please let me know how this can be achieved through PHP.
thank you for your replies.
I am able to get the drop-down options with the below code segments put at the 5th tag.
echo "<td align='center' font face=verdana size=2 color=#000000 >"; //Severity
echo '<select name="priority"><option>Select</option>';
echo "<option>"."default"."</option>";
echo "<option>"."P1"."</option>";
echo "<option>"."P2"."</option>";
echo "<option>"."P3"."</option>";
echo "</select>";
echo "</td>";
I can see the changed code working on my php page. Thanks for reading this question.