Hello, i was wondering if there was a way to give data to an html select box using php and reading that data from a text file
The html syntex for creating such a select box is the following!
What changes must i make in order to make it read data from a php file?
<select name="cd"> <option name="1">One <option name="2">Two </select>
I can also load the contents of the php file to an array using the following
$data=file("data.txt")
Pls help me out with this.....
Html Select Box and php
Moderator: General Moderators
dont you need </option> tags?
i normally use a while loop
i normally use a while loop
Code: Select all
$selectfeed = '<select name=monkey>';
while($data=/*datasource*/)
{
$selectfeed .= '<option value="' . $dataї'this'] . '">' . $dataї'that'] . '</option>';
}
$selectfeed .= '</select>';-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
Thank u very much guys for your help! Can u pls tell me pootergeist how can i paste this solution to the following cause i didnt fugure it out.
<form action="check.php" method="post">
<table border=1 width=50% align=Center bordercolor=Yellow style='border-style: solid; border-width: 5' background=pics/blue.jpg>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 1ης ταινίας? </td>
<td align=center> <select name=dvd1> <option name=1> Die Another Day </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 2ης ταινίας? </td>
<td align=center> <select name=dvd2> <option name=2> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 3ης ταινίας? </td>
<td align=center> <select name=dvd3> <option name=3> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 4ης ταινίας? </td>
<td align=center> <select name=dvd4> <option name=4> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 5ης ταινίας? </td>
<td align=center> <select name=dvd5> <option name=5> Ένα </select></td>
</tr>
</table><br><br>
Aso the txt file is like
text1
text2
text3
with no pipes before it
Thanks again!
<form action="check.php" method="post">
<table border=1 width=50% align=Center bordercolor=Yellow style='border-style: solid; border-width: 5' background=pics/blue.jpg>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 1ης ταινίας? </td>
<td align=center> <select name=dvd1> <option name=1> Die Another Day </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 2ης ταινίας? </td>
<td align=center> <select name=dvd2> <option name=2> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 3ης ταινίας? </td>
<td align=center> <select name=dvd3> <option name=3> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 4ης ταινίας? </td>
<td align=center> <select name=dvd4> <option name=4> Ένα </select></td>
</tr>
<tr>
<td align=center> <font size=5 color=LightGreen> Τίτλος 5ης ταινίας? </td>
<td align=center> <select name=dvd5> <option name=5> Ένα </select></td>
</tr>
</table><br><br>
Aso the txt file is like
text1
text2
text3
with no pipes before it
Thanks again!