Jump to content

MikeEller

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MikeEller's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. OK, That worked. Now when I am prompted to save the file....and I select a place to save the file....it saves it to my selected location but the file is empty. However, the file as I want it to b (with data) is also saved in the folder where the php file resides. Another words, it is not saving data where I want it to. the "filename" in the header is where the file is actually getting saved. Is there a way to override this? Thanks, Mike
  2. I have a function to save table data (read from oracle) to a csv file. The function works fine. The problem occurs when I add "header" to the function. If i use header to prompt the user to save the file, the entire page is saved to the file not just what I output to the file. I cannot put the code here...as it is on a different network computer. In a nutshell I have: functionName() { header('Content-type: application/excel'); header('Content-Disposition: attachment; filename="filename.csv"'); readfile('filename.csv'); HTML and php code to display the page Then code to read the data from the database and write it to the file if the user clicks on the "save to excel" button. } Like I said, if I do not use the headers, the file is written perfectly. If I use the headers...the entire page, to include the html markup, buttons, everything, is written to the file. So I am sure I am missusing the headers somehow. Any suggestions?
  3. That is what I would be doing....replacing a string of If....Else (or a string of nested If...Else) blocks with a string or hierarchy of functions. That is what I want to know...which is best/more acceptable/correct? The code will not be called but once per user to make date based reservations. Each user would not make multiple reservations. So the code would, theoretically, be used no more than 52 times per year. I will post the function if needed. But I am just looking for the correct approach to this. Thanks, Mike
  4. I thought about using a switch...and just letting it fall through when appropriate.... but the decision points are not related that way. Now what I was thinking of doing is say having an If....Else block for one test level and calling a function based on that point. then inside the called function have the next level If...Else block and again call another function based on that decision....and so on. Is this something that is logically or functionally acceptable or not? The code is for calendaring. So it is checking given dates against other dates, previously selected dates, based on year, month, time of year. So there is at least 5 levels of If...Else blocks and the code goes in a different direction based on each level's decision. I was thinking I could use a function at each decision level and pass in a parameter based on the decision. So I would have to work through 5 functions. To me it looks good on paper....but is it the right way to do things? That is my question. Thanks, Mike
  5. Hi, I have a function that must work through several layers of decision points. Right now implemented with nested If...Else blocks. Many times the decision arrived at must implement the same code with just a change or two to variable values and such. And it is getting difficult to follow. My question is....is it acceptable coding practice to place function calls inside the If...Else blocks? This, in my mind would make the code more readable and easier to follow the logic. However, do I lose anything in all the function calls? The If...Else blocks would remain, I would just be able to call different functions with different parameters to do the work. What is the best approach when dealing with a high degree of complexity of decision points? Thank You, Mike
  6. Hi Forum, How can I move to the last record in a table [directly] in mysql using PHP? Thank you, Mike
  7. Hello, I need to be able to get the selected value from a dropdown box on a form. I have found many ways to dynamically populate the dropdown box, but nothing to get the selected value. I have something like this (it might be wrong as I am not at home so I cannot see my exact code): <?php if (isset($_POST['add'])) { $category = $_POST('category'); ?> <form name="newloc"> <select name="category"> <option selected> <option>Item One <option>Item two <option>Item Three </select> <input type="submit" name="add" value="Add"> </form> Like I said, there is probably some errors here....but this is the gist of it. I know this is how to get the data from a text box, but I need it to get the value of the selection of the dropdown box. Any help is greatly appreciated. Mike
×
×
  • 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.