Jump to content

Writing PHP to Excel


tacophp

Recommended Posts

Hi All,

 

I have a basic PHP form that prints the results out to an Excel file. The file is kind of a hybrid of 2 functions I borrowed form the web (GNU Open source stuff)

 

The first half of the code makes fields that have a name="_req_xxx" in the HTML required fields for users. the second half of the code prints results to an Excel sheet stored on my server.

 

Here is the code: http://www.uah.edu/coop/new_folder/php.html

 

Here is the form online: http://www.uah.edu/coop/session/

 

1st Question: When the results are printed to Excel, the headers still have _req_ in the name. I have not figured out how to merge both halves of the code into one, so that _req_ is removed before print out.

 

2nd Question: I need to figure out how I can incorporate check boxes into my form, so that when results are printed to Excel, a cell can hold multiple values separated by commas.

 

thank you,

Jonathan Wright

 

 

 

 

Link to comment
Share on other sites

Hmm...

 

I only took a cursory look at your code and I'm really not understanding what you are doing. I expect you are using the "_req_" as a lazy way of doing validation. Why? I would suggest you should explicitly state what fields need to be validated and what validation should be done. I notice on your form that EVERY SINGLE FIELD IS REQUIRED. That makes no sense to indicate all the fields as required on the form itself (You should do the appropriate validation on the receiving page, of course). But, your SELECT fields all have "valid" values. So it is impossible for the user to not have a valu in that field. Same goes for your radio groups - you have an option selected by default so the user can't not select an option. If you have a "--SELECT ONE--" or similar field in a select list that has no value or if you don't select a radio group option be default, then it would make sense to mark them as required.

 

As for your second question, I would make groups of checkboxes an array by giving them the same name such as "fieldName[]". Then the receiving page will be able to access the array of values for a group using $_POST['fieldName']. Just do an implode() to convert the array to a string and add the commas.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.