Jump to content

Evan69

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Evan69's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks alot, it works perfect. i knew my way was way too complicated!
  2. Hi, im working on a script where i have the user ids stored in a field separated by periods. I am trying to create a function that can subtract two sets of users so it would basically complete the equation: 1.2.3.4 - 2.4 = 1.3 So far i have managed to get it so you can subract one number from an array, but i am stuck as to how i would subract a set of numbers? Heres the code i have, theres so other stuff in there that isnt so important, its the second half of the function that matters: function get_users($minus) { $this->query = mysql_query("SELECT * FROM cal_users"); $num = mysql_num_rows($this->query); $users = array(); $out = array(); if($num > 0) { while($res = mysql_fetch_assoc($this->query)) { array_push($users, $res); } }else{ $users = ''; } //This is whats important if($minus > 0) { $del = explode(".", $minus); foreach($users as $user) { if($user['id'] == $minus) { continue; }else{ array_push($out, $user); } } }else{ $out = $users; } return $out; } Any help would be much appreciated!
  3. wow, thank you very much, i've been stuck for an hour on this!
  4. Hi, im righting a calender script in which the events need to be over a period of several dates. Dates are in format of (YYYY-MM-DD). I will have the user enter a start date and an end date, i then need a script to find all the dates inbetween the start and end. Here is the script i have to find the difference between days, unforutanetly i cant think of a way to find the dates when the years or months are different. Any help would be much appreciated. <?php //yyyy-mm-dd $start = '2007-11-01'; $end = '2007-11-05'; //the start day is $start[2] and end day is $end[2] $start = explode('-', $start); $end = explode('-', $end); for($i = $start[2]; $i <= $end[2]; $i++) { //there cant be any 1 digit numbers if(strlen($i) < 2) { $i = '0'.$i; } $dates .= $start[0].'-'.$start[1].'-'.$i.' '; } ?>
  5. foreach($this->vars as $k => $v) { $this->contents = str_replace("{" . $k . "}", $v, $this->contents); } thats a pretty simple way of replaces an array of tags: $this->vars (example: array("TITLE" => "Home Page", "BODY" => "Welcome...")) in the template file $this->contents.
  6. I would just make another table for catagories. Its not much harder than implementing the catagories in the scripter and makes the script much much more flexible, unless you are 100% certain the catagories will never chance, even though i would still use another table in that case.
  7. probably the first one, but its not really gonna make a difference, the class is too small for you to worry about design.
  8. yeah your best bet is to use a content management system (see google).
  9. just make sure you havent outputted anything before you use header("Location"), otherwise it wont work.
  10. yeah, apart from the query everything looks good.
  11. okay, thanks that was exactly what i needed.
  12. Hi, i've been working on a templating class, i've got a fully functional class that simply replaces the {TAGS} but what i cannot find a way around is including loops in my class? There are no tutorials on it and only the big engines like smarty have support for loops, and the code is way too complex for me to use it. Im looking for a simple function or functions that will be able to include loops in my class. Any help would be much appreciated.
×
×
  • 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.