Jump to content


  • Posts

  • Joined

  • Last visited


Posts posted by bibby

  1. how's your php , faizulbari ?

    You'll definately want to do two things,  separate your different registrations from each other and then separate the data for each registration. When confronted with a outside form, you can still submit to the post handler after writing your own form.

    :load up the file:
    Read and adapt the user scripts from these pages.
      echo "I can't find $file";

    :separating records:
    Hopefully, each new record is on it's own line. file() as already split them into an array.
      foreach ($f as $index=>$text)
        foreach($x as $k=>$temp)


    Now you have an array of arrays.
    print_r($parts) to see it.
    I imagine it's something like

    [code]parts= Array(
                      0 = Array(
                      1 = Array(

    I'll leave the rest up to your imagination, but what you could do with this giant array now is use it to create 100 new forms that just need their submit buttons touched. Or, and I like this one, make a page that has 100 forms (hidden text of course) and 100 submit buttons. In 100 clicks, yer done.
  2. I'm trying to blow your mind or nothin,  but you can do your flags in a single field, if you felt like it, using bits.


    Say you have 4 flags (quests in a game).

    ! - Defeated Ogre
    ! - Saved the old man
    ! - Helped Timmy out of the well
    ! - Slayed the Dragon

    Any could be on or off at any given time.
    Assign them binary values relating to decimal place.

    1 - Defeated Ogre
    2 - Saved the old man
    4 - Helped Timmy out of the well
    8 - Slayed the Dragon

    If I saved the old man and helped timmy, my number is 6.

    Some bitwise operators are '&' , '|'
    (ever wonder why you've been using && and || ?  These are tests for truth, return 1 or 0)
    if (($myNumber & 2) == 2)
      echo "you had saved the old man";

    6 in binary is 110 .
    2 in binary is  10.

    0110 &  (& finds like bits)
    0010 =

    To try to answer your question though, you could use a function. Write it once, use it wether you have 31 fields or 31,000 fields.

    function countFlags($flagnum)
      $q=mysql_query("select sum($flagnum) from flags");
      return $r[0];

    function countAllFlags()
              $list.=$i . ' - ' . countFlag($i)
      return $list;

    echo countAllFlags();
  3. [url=http://www.jedit.org]http://www.jedit.org[/url]
    Jedit is by far my favorite text editor for a number of reasons (all platform being number 1),
    but the "dry install" doesn't have everything that you'd want. This is easily remedied, so here's a short To-Do to get you rolling with Jedit.

    Firstly, it doesn't have FTP/SFTP out of the box, you'll have to get it as a plugin. But the default site that it tries to get plugins from is unresponsive most of the time, so select a different mirror:

    From the top menu, select Plugins -> Plugin Manager -> Download Options -> Update mirror list -> (pick something other than Central default, like UofM). Now you can get your plugins.

    FTP you'll want for sure.
    BufferTabs is great if you don't like the dropdown for open files.
    PHPParser is great if for your PHP scripts (includes dockable panes for error checking and class/function structure).

    I suggest getting to know how what your docking options now (Utilities->Global Options->Docking).
    I keep my Structure browser and ErrorList docked left, and my BufferTabs docked at the top, but that's just me.

    Take a few minutes to play with the colors too. I love having a black background.
    (Global Options ->  TextArea , SyntaxHighlighting)

    mmmm,  Jedit.  ;D
  4. Leon,
      I've been back and forth on this topic ever since php 4 was released, and I'm still more on the side of class-less "procedural code".

    The biggest arguments that I've absorbed for using classes is portability. A "good" class should not try to do too much, it does what is does and and that's it, making it so that you can begin a brand new project and still be able to use that class and not worry about it failing.

    Classes can also share functions. Say I have a database object and product object, and there's a method of product that I want to apply to my database widget. I shouldn't add a special function to the database class because I'm using that for every project that I own, but I don't have to. I don't even have to think about it though, I can use a product function whenever..
    // one object using another's function.[/code]


    Another idea.
    You begin to wish you were using objects as soon as your functions begin to take four or more parameters. A lot of your most complicated functions could take one, the object, and work itself out from within. The object in that instance is just a big array.


    Final thought.
    In some languages (from what I understand C++,Java, don't really know), classes and objects are a must in order to do anything. Adding Object oriented syntax to PHP is, in my opinion, most beneficial to those that are already used to being in that state of mind. It is argued as well, and I agree, that PHP's objects aren't really objects anyhow, as PHP is an interpretive language, so it's all kind of a rouse.

    I'm only posting here to begin the discussion. I'm really asking the forum the same question, Leon. I'm not completely sold on PHP objects, and continue to write procedural code more often than not.
  5. yeah,  don't put your function call in window.open,

    (!)  window.open('[b]constructCalendar()[/b]')

    call a different function that does both.


    function launch should then call window open.

    What does construct calendar do? Is it something that the destination page should handle instead? Because once that window's open, there's only so much you can do with it from here.
  6. [code]
    //lol, great name for this fxn.

    function valiDate(input) 
          //gave it an id ?
        var ymd=input.value.split('-');
        if (ymd[0].length=='4'  && !isNan(ymd[0]))
            // is a number by  !isNan?  (not (is not a number)?)
            var yeargood=true;
          else { var yeargood=false; }

          // ect.  same for month, same for day.
          // return in the end,  true or false,  handle as you see fit.
        // else there is no id for that input
  7. [quote]I don't want to create each level by hand, because you never know how many levels deep the subdirectories[/quote]

    Right, so you right a function for it that can recursive onto itself

    function readDirectory($dir)
        //blah blah, read files
        while ($file)
            readDirectory($file);    <----  recurse!!
          # whatever you do with files

    Call the function once on your target directory, and it should handle any depth.
  8. cturner, you defiantely need to learn how to use functions for repetitive tasks.
    If I find myself doing ANYTHING twice, it becomes a function.

    That aside, you have some error handling (visually checking the post),  but you don't have the good stuff.
    If your query doesn't run,  echo mysql_error();
    echo'ing out $update could help as well.

    I bet that the hint you want is in mysql_error();

  9. time() is an ok solution if you are always going a year from now, but memberships are most often renewed before they expire.

    So if my expiration date is 2007-06-01 (date format, not unix time), and I wanted a add a year from THEN, try
    update members set expDate =
    where mbrID=1;

    That gets you year beyond what I'm already due.
    Be careful that if the membership is expired already not to shirtchange them, (use now)
    concat( date_format(now(),'%Y')+1 ,date_format(now(),'-%m-%d'))
    #year from now without php

    How you handle leap years is up to you. What you consider correct is correct.
    This method grants the occasional 366 day-year.
  10. My friend is using picture trivia, using random photos found on the net. There are a series of questions possible questions associated with each photo, so the photo can be reused. This of course is not a very good use of his time (creating questions and answers), when it should be random.

    For example, a photo of hot babes at a bar. Questions would be, "What color is the redhead's shirt?", "How many bottles are on the bar?".

    What's the problem with captchas anyhow?
  • 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.