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, 07: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, 09: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, 10:10 AM
MatthewJ MatthewJ is offline
Contributing User
Click here for more information.
 
Join Date: May 2007
Location: Davenport, Iowa
Posts: 564 MatthewJ User rank is Private First Class (20 - 50 Reputation Level)MatthewJ User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Week 21 h 23 m 45 sec
Reputation Power: 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.

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




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek