Jump to content

PaperTiger

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by PaperTiger

  1. Have you tried running the script in the browser and seeing if it works then?
  2. Because you set the count as 3 before you unset the first element, so it will always loop through 3 times. You don't really need the count at all. You can just do: unset ($shop[0]); foreach($shop as $item) { echo $item["Title"]." costs ".$item["Price"]." and you get ".$item["Number"]; echo "<br />"; }
  3. I originally had them generated as PDF documents, but found it to be very unreliable no matter what library I used, and it didn't work cross browser either, so I went back to HTML. If they were generated as PDFs though, surely it would run into the same issue of having to sit there loading up an enormous file for hours on end before it would actually print off?
  4. I would advise staying away from Plesk, it's a poor product.
  5. Readability and making it easier to debug later on.
  6. Hi, We have various reports which can be printed off by our staff, for each individual student, which work by generating a simple HTML page and then using the javascript print method on the document load to print it off (or Ctrl+P, whatever it's just a normal HTML page). Pretty standard and simple. However, one of the managers has decided in his infinite wisdom and obsession with printing everything that he can, that he wants to have one button which he can click to print off all reports for every student in the system. Now since these reports are generated at run time, building up the HTML page, I can't see any way to do this other than literally have it create one massively long HTML page with all the reports, which will no doubt take hours and hours to load, and then just print in the normal way. Is there any other way this could be achieved? The only other thing I can think of at the moment is change it so that when a report is generated it saves a copy to a file somewhere, but even then it would still have to load it up in order to use the javascript print method, and there would be plenty of reports that won't have been run yet, so they would still need to be generated, and as php is server side I am 99% sure there's no way for it to communicate with the client's printer to just say "print all these things". Any ideas at all? Cheers.
  7. Could you put the code in code tags? It's much easier to read that way.
  8. If you want to get the array key in your foreach, you can do: foreach($_POST as $key => $value) A few other notes: - Rather than just checking if the value = "", you may want to trim it first. As if someone enters a blank space I would assume you'd want that to return an error about being empty, but it wouldn't because " " != "". There is also a function in php called empty() which checks if a variable is "empty", though depending on the variable type it can produce unexpected results sometimes. - Where you're doing "return array($ERROR_Specify);", you have already said that $ERROR_Specify is an array, so you don't need to then put that array into another array unless you have some other reason for doing so.
  9. If you want to execute a PHP file in the cron, you need to specify the path to the PHP command line interpreter. If you're using linux, this is generally "/usr/bin/php" So the cron would look like: * * * * * /usr/bin/php /path/to/file.php Replacing * for whatever time values you actually want
  10. ^ Pretty much that. All you need to do is pass in the parentID and assign that. Consider: ID: 1 comment: "First Comment" parentID: NULL ID: 2 comment: "Second Comment" parentID: 1 ID: 3 comment: "Third Comment" parentID: 2 By simply specifying the parentID when doing the reply, you can then get a recursive list of all the comments so that you end up with something like: Comments Array ( [0] = Array ( ID: 1, comment: "First comment", parentID: NULL, replies: Array ( [0] = Array ( ID: 2, comment: "Second Comment" parentID: 1 replies = etc...... ) ) ) )
  11. If you want to use php to redirect to another page, you have to follow the "no output before the header" rule. Even a new line or some whitespace will cause the "headers already sent" error because it is output that has been sent to the buffer. Either : A) Get rid of the output before the header call. B) Clear the output buffer before the header call. [more info] C) Use javascript to do the redirect
  12. You'll have to be way more specific as to what you mean...
  13. Try unbinding the click event before you set it: $(function(){ $("a.load").unbind('click'); $("a.load").click(function (e) { e.preventDefault(); $("#pdetails").show("slow"); $("#projd").load($(this).attr("href")); }); });
  14. The password must be blank, otherwise it wouldn't work.
  15. That simply means that there is no file called "mailform.php" which you are telling the form to post to. The "action" of the form should be whatever the name of that file you just showed us is, if you want to post it to the same file, which presumably you do.
  16. I'm looking for some advice on the best ways to handle the "view" part of the MVC pattern, specifically the loading of the view files, dependent on where you are in the system, what actions you've called, what the system requires, etc... In my previous projects, I've gone about this generally in two different ways. Method A: Example URL: mysite.com/report/view/1 Flow: Various routing & file including occurs Eventually this calls ReportController->view(1) which does whatever it needs to do..loads up a Report model with parameter "1", etc... Within the view() method we set the variables that we want to use in the ReportTemplate On __destruct of that controller object it calls Render() on the ReportTemplate object This Render method looks in "modules/reports/views" for 3 files: "header.html", "footer.html", <action>.html (in this case "view.html" If it can't find the <action> view, it looks for "index.html" If it can't find any of those files it loads the global files This way it automatically looks for a specific view for whatever module & action we have called Downsides to this include: Fairly limited in the layout as always have to have header, <action>, footer unless we override the Render() method for particular Templates, which isn't that big of a deal, just seems inelegant Might want to call a different template rather than just rely always on working it out from the querystring Method 2): Similar to Method A, but rather than having seperate template classes for each module and an overall Render() function that works the views out by itself, we manually load whatever templates we want, eg: ReportController->view(1) Does stuff Creates new Template object Template->set("somevar", $somevar)->set("var2", $var2)->etc... Template->load(/path/to/chosen/template) Template->display() Template->load(/path/to/some/other/template) Template->display() etc... Downsides of this include having to manually do it all the time. But it does allow to load whatever template/view you want, whenever you want. I'm aware neither of these is probably a particular good way to do it, so I was wondering what the best practices would be to actually handle the loading of views/templates in real-world professional systems. Thanks.
×
×
  • 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.