Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. THere are plenty of good books on the subject, and good articles on OOP for that matter, but there's also some excellent OOP Frameworks out there, which are FOSS and you can download them and study them. For a start, try Zend Framework. It has various classes and you can read the code and look at what they're doing. There are also "design patterns" which are frequently used in software development. Often frameworks implement design patterns because they are known to solve certain common design problems. For example, the Model-View-Controller pattern is implemented in many frameworks. The specific code is built around the basic idea of the pattern, and has been implemented in many different ways, but it's fair to say that most of the popular php Frameworks have implemented some variation of that design pattern using a number of different classes. So in the aforementioned Zend Framework, there's a view class and a controller class you can look at right off the bat. In just taking a really cursory look at your code, you haven't really done something that's particularly oop yet. This is self evident, because you have created a class where the objects have no properties. At this point you might just as well have an include of the functions, because there's nothing really binding them together. You have the right syntax, but OOP allows you to step back and think about the objects inherent in a problem. For example, since your problem involves "users" wouldn't it make sense to have a user class? Once you start thinking about what a "user" is, then you can start thinking about the properties of a user... things like username, password, permissions, etc. When you look at other class libraries, you may find that they change your approach to the problem.
  2. No worries if that solves his problem, but it wasn't what he asked for. He asked to click a button -- display a message and then do the download, so I discounted the meta refresh.
  3. Take a look into the javascript setTimeout() function.
  4. I'm not clear on how this form fits into things, but you can pass a form item using a hidden field if you're just looking for a way to get it out through the POST variables. There's no advantage to that over reading it directly from the $_SESSION, and often people are doing that help with security. These statements don't make any sense: Either echo $display_block or $item_bio. Don't know where those variables are suppossed to get their values from, as their not in evidence in the script, and thus would be empty and not set.
  5. FWIW, Alex W.'s advice is considered best practice from an OOP perspective, as it implements the concept of "Information Hiding". If you're studying OOP, it's a good idea to look carefully at the scope keywords: public, private and protected, and the ways they effect variables and class functions in regards to inheritance and via general use. Making the variable private means that it can't be accessed directly in the way I did, which is often considered a good thing by class designers who want to be able to change internal class data storage details without breaking applications that use the class. With PHP's loose typing this isn't as big an issue as it is with other languages, but at least you get an idea of why there's 2 different examples presented.
  6. We are here to help people learn So, your class definition needs to have variables to store key pieces of information for later use. If you need to access the $student_name you need a class variable to store it in, and you should do that in your __constuct(). Then later you can access it using a get or, if you declare it to be public via direct access. class Student extends Classroom { public $student_name = ''; static public $student_count = 0; public function __construct($student_name) { echo "Hello {$student_name}! "; $this->student_name = $student_name; parent::__construct(); echo "The number of students in your class is: " . parent::$class_attendance . " "; self::$student_count++; } } Add the variable and set it in the __construct() like so, and you should then be able to do: echo $student1->student_name;
  7. I'm sorry if you took my comment in that way. I have no opinion on your degree of frugality -- only the ground rules of the community. Usually when I make a reply like my original one, it starts a dialogue because the person either starts to dig into the matter themselves, or doesn't understand the advice. I assumed since you indicated in your post that you had modified the original package, that you had done some degree of customization of it. Certainly there are people here who are altruistically motivated, but this is still a forum for developers. If we didn't say no, we would be innundated with people who simply wanted free programming services. As it is, there are many experienced php developers who frequent here, and we provide the freelancing forum to allow for people to advertise to them. I don't have any real statistics since we maintain a handsoff approach to that venue, but I would guess that literally hundreds of people have secured programming services via that forum, at no cost to them in terms of advertising fees or commissions. I will say, that depending on the degree of bells and whistles, your request could be knocked off by someone who knew what they were doing in an hour or 2, and you could probably get that work done for a very reasonable amount. Best of luck.
  8. I don't see how that helps you. What makes more sense is to store the current Date. Your clientside ajax or whatever, can periodically check this at the server. If on any poll, the startDate != the serverDate, then you do your reset. Needless to say the date changes at midnight, but when you think about it, midnight is simply an indication that you're in a new day.
  9. Did you read what I wrote 2x now about calling mysql_num_rows()? // $result = mysql_query(.... $rowCount = mysql_num_rows(); if ($rowCount echo "There were no rows found."; } else { // fetch the rows in a while loop and output } //
  10. Yes we get that, but the point is, that the count query always returns a result set. That result set will have one row, and that row has the column which contains the count -- either 0 or > 0. The question is -- if you only need the answer of whether or not there is at least one row that matches the criteria then you can do that with the COUNT(*) query. If you're not going to do anything with the result set, it doesn't make sense to do the query you're doing where you select some number of rows, but never fetch them. If the count of rows > 0 AND you then will fetch those rows, which is doubtful due to the fact that you were using a LIMIT 1, then you can use the mysql_num_rows() function which will also get you the count of rows in the result set, but will also allow you to fetch them.
  11. So the decision to structure this using multiple tables is yours? What exactly is "too much data"?
  12. There is no simple way, although as mentioned by Jimania, there's a javascript library that attacks the problem. The issues are: -There's no base html support for the idea -Trying to do it with css involves hacks or browser specific extensions -IE seemingly always has to go its own way, or outright suck So many sites these days rely on javascript, that it's hard to argue with its ability to perform magic and even out the rough edges.
  13. With PHP you could write a script that parses up the date range and determines how many of the tables you need to UNION together, using your tablename convention of 'reportsYYYYMM'. Ugly but it could be done. As PFMaBiSmAd stated, this is the reason that putting data in seperate tables like that is a really bad idea.
  14. Sure, however, the way checkboxes work is an html thing, not a php thing. With that said, this is a pretty common question.
  15. That's on paypal's side, via a callback. So the answer is... you put the logic you need in a seperate callback script that paypal will then call to.
  16. Your blocks need to match { .... } Notice how you used { .... and then { again.
  17. PHP interpolates strings, and I try and make use of that for readability, rather than using concatenation all over the place. $sql = "SELECT * FROM $table LEFT JOIN $table$Themes2 USING (Name) LEFT JOIN $table$Methods2 USING (Name) WHERE $table.Name = '$item'";
  18. What do you expect, you use every variable in the $Body string without checking to see if any of them exist. Checkboxes will exist in the $_POST if checked, otherwise they will not exist. As almost all of the variables are checkboxes, there's no reason to be doing a trim(stripslashes) on them. For those all you would need is: $IndyCar = isset($_POST['IndyCar']); // Later on if ($IndyCar) { $Body .= "Fan of: IndyCar\n"; }
  19. If all you want is the count of rows, it would be a lot more efficient to simply query for that ie. SELECT COUNT(*) as countof FROM content WHERE cid = '$conid' ... Notice no need for LIMIT etc. If you might actually want to fetch the rows, then you can use the mysql_num_rows() function to get the number of rows, and check to see what that is.
  20. This isn't a script writing service, it's a php programming help community. I gave you all the information needed on the specifics. I mean, unlink() -- it's a simple function. If all you want is someone to code changes for you, you should consider posting in the freelance forum, and paying someone a fee.
  21. The way html works, is that checkboxes exist in the POST data when they are checked. When they are not checked they don't exist.
  22. The system is pretty primitive. From looking at the admin.php script it simply makes files in the ../news/ subdirectory with the name of the file being "title.txt". PHP offers the unlink() function to let you delete files, so you could pretty easily either alter the admin.php or create a delete.php script that lets you input the title of a news file for deletion. Alternatively you could code things to move the file to a different subdirectory, in essence hiding it. You'd use the rename() function for that.
×
×
  • 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.