|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
php5 - ReadFile, Make Page then POST
I am trying to make a php/sql page that reads a text file that has a header row, then displays the rows and allows the user to select what type of information each row contains. For some reason I cannot get the POST method to work on the select boxes that I generate. Let me know if there is a easier way to write this or if there is something that I have done wrong.
fileRead.php //all this **** works as far as opening a file $filename = "path.txt"; $fd = fopen($filename, "r"); $contents = fread($fd, filesize($filename)); $delimiter = "\n"; $splitcontents = explode($delimiter, $contents); $headerRow = explode("\t", $splitcontents[0]); $x = 0; $con = mysql_connect("localhost","user","password"); mysql_select_db("contact", $con); //This will work echo "<table border='0'><form method='post' action='fileInsert.php'> <select name='test'><option>ABC</option><option>123</option>"; echo $headerRow[$x]; //This will not work while($headerRow[$x] != ""){ $row = $headerRow[$x]; echo "<table border='0'><td>".$row."</td><td> <select name=".$row.">"; $fields = mysql_query("SELECT * FROM fields", $con); echo "<option></option>"; while($row = mysql_fetch_array($fields)){ echo "<option>".$row[fieldTypes]."</option>"; } echo "</td></table>"; $x++; } echo "<td><input type='submit' name='submit' value='Insert'></td></form></table>"; So this part works perfectly as far as populating the select boxes and showing the names of the header rows. Employee Number [SELECT BOX] Full Name [SELECT BOX] Date Of Birth [SELECT BOX] Date Of Hire [SELECT BOX] Grade [SELECT BOX] [SUBMIT] My problem is, when I hit submit. The top select works and displays ABC and Grade but if there is a space in it it wont work, Employee Number in this case. Is there any way to remidy this?? A easier way to do the whole thing?? <?php echo $_POST["test"]; echo $_POST['Employee Number']; echo $_POST['Grade']; ?> |
|
#2
|
||||
|
||||
|
Try double quotes
echo $_POST["Employee Number"];
__________________
The thinks you can think. |
|
#3
|
|||
|
|||
|
Both single and double quotes are valid so that should not be the issue. I think some more info is needed to answer this one... for instance the structure and contents of the txt file and db.
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > php5 - ReadFile, Make Page then POST |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|