Jump to content

Bladescope

Members
  • Posts

    59
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Bladescope's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Whoa, thanks for the topic attention O.o. I think the general method I've been taught is to create a page/template class, and to use that object to take the raw template data and insert the data in that way. I've usually used something like str_replace for that. As for the singleton pattern, I've been using the singleton pattern for one class only, which is my main control class to save passing the object through to each object who needs to use it. I don't particulaly know if it's the best option, most likely isn't, but I haven't been taught otherwise. I am aware that using the singleton pattern breaks encapsulation, and that it probably would actually be better to go with the other method mentioned in my post, so I may change that around now. In the meantime, I'll continue reading about the theory behind OOP which you kind folks have provided. Once again, thanks for the feedback. I'm still here! Edit: As for the law of demeter, I assumed that was the standard way to approach OOP, so I've been using that logic from the start. (:
  2. Hey PHPFreaks! I'm designing an online application using OOP. This is by no means my first application, but it is using Object Oriented techniques, so I come to you helpful folks with a question.Essentially, I would like to be able to find out about recommended ways to approach page templates in a class design, as well as other general good class design practices specific to server-side languages. So, without further ado, what is considered a good/recommended method of approaching template design using OOP? For example, a base template class which can be extended for multiple themes, so additional themes don't have to recreate the core functionality if they decide not to change it. It seems that there are a lot of methods to approach it, which is why I'm here! Any help you can provide would be greatly appreciated!
  3. Google Analytics is a great way of tracking hits to your website. Easy to use too, most websites use it including phpfreaks!
  4. function addToWords($string) { $array = split(' ', $string); foreach($array as $key=>$value) { $array[$key] = '+'.$array[$key]; } $return = implode (' ', $array); } Probably an easier way of doing it, best I could think of off the top of my head (without going into regex)
  5. That should work, I don't seem to find any problems with it
  6. First thing is first, the functions theory is wrong though I can see why you thought that. If a function is declared in the script, it can be used in other functions without needing to be (re)declared in the function it's being used in. Next thing, I need some info. Which of the two no-entries errors are you getting? "No Results found!" or "No results due to database error." Also, have you tested out the query on it's own? I.e. hard coding a name into the query's WHERE filter to see if it returns results there? (using either a new, fresh page or something like phpmyadmin to test it)
  7. It would be safer to edit out your username and password for the sql connection in the text file before you upload it to the net. Looking at the code now.
  8. Gaogier, You can change the double quotation marks to single marks if you're not going to be inserting variables in between the quotes. e.g. echo"<img src=\"images/none.gif\" height=\"11\" width=\"11\"> <a href=\"calculate.php?action=enter_name&skill=".$name."&members=".$mem."\">$calc_name</a><br>"; can be simplified to echo '<img src="images/none.gif" height="11" width="11"> <a href="calculate.php?action=enter_name&skill='. $name. '&members=' .$mem. '">'. $calc_name. '</a><br>'; Just makes things a little easier on the eyes in my opinion . I don't understand :/
  9. Looking at the script now, just a note to wrap your code in [ code ] or [ php ] tags, it helps keep pages clean :3. Edit: Javascript is a good way of handling form validation, but it's also very insecure as users can diasble javascript. Best case scenario is to use both, but never use JS alone. Edit Edit: Based on the way you have structure your code, there's a few things you need to change. First off, it's always good practice to indent your code properly. Next, it's also good practice to use braces for each conditional statement. e.g. if(empty($Password)) $error4 = (' You must enter a password'); else $Password = $_POST['Password']; into if(empty($Password)) { $error4 = (' You must enter a password'); } else { $Password = $_POST['Password']; } On one of your checks, you use two lines to set two variables. Without braces, the conditional statement only checks one line. This is why braces are important! Also, near the end of your script, after the strangly placed exit(); and closing brace is an opening brace following it straight away without else or elseif.
  10. No problem :3. I had to make a small emulation from the table structures you gave me on my local server to test it all out. Good fun, really trivial and awesomely satisfying :3.
  11. SELECT forum_posts.post_id, forum_posts.post_name, COUNT(comment_id) FROM topics_read LEFT OUTER JOIN tbl_comments ON (topics_read.topic_id = tbl_comments.post_id), forum_posts WHERE topics_read.read_at < tbl_comments.date AND topics_read.topic_id = forum_posts.post_id AND topics_read.user_id = '{$member_user_id}' GROUP BY (forum_posts.post_id) This query returns each topic's id and name with the number of newly posted comments (since the user last checked). Finally figured it out . Edit: Well, you can make a foreach loop for each row returned. That way, you can get the data for each seperate topic using the topic id (aka post id) as a filter
  12. This is rattling my brain =p You see, a small thing is that you're wanting to seelct forum topics with posts > last viewed time. Thing is, you're also wanting to select a comment poster's id, note how it's single. A problem with that is, if multiple commenters post on the same topic after you have viewed it, SQL will give back an error because it's trying to select a single value from multiple options. I'm still working on it, don't worry
  13. SELECT DISTINCT forum_posts.post_name AS post_name, forum_posts.post_id AS post_id, tbl_comments.user_id AS commenter_id FROM tbl_comments NATURAL JOIN forum_posts ON (tbl_comments.post_id = forum_posts.post_id) NATURAL JOIN topics_read ON (topics_read.topic_id = forum_posts.post_id) WHERE tbl_comments.comment_type = 'forum' AND topics_read.user_id = '{$member_user_id}' AND tbl_comments.date > topics_read.read_at Try this first. I'll be amazed if it works but it probably won't. Tell me what error gets back if it does fail. ( using mysql_query(...) OR DIE(mysql_error()); ) Edit: Changed some syntax.
×
×
  • 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.