PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old July 8th, 2008, 06:00 PM
fzfowler fzfowler is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 fzfowler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 58 sec
Reputation Power: 0
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'];
?>

Reply With Quote
  #2  
Old July 11th, 2008, 08:44 AM
xybrdragon's Avatar
xybrdragon xybrdragon is offline
resU gnitubirtnoC
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: OK, USA
Posts: 22 xybrdragon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 7 m 46 sec
Reputation Power: 0
Send a message via Yahoo to xybrdragon
Try double quotes

echo $_POST["Employee Number"];
__________________
The thinks you can think.

Reply With Quote
  #3  
Old July 11th, 2008, 09:10 AM
MatthewJ MatthewJ is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: May 2007
Posts: 235 MatthewJ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 Days 8 h 18 m 17 sec
Reputation Power: 2
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > php5 - ReadFile, Make Page then POST


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT