PHP help

Discussion in 'General Off-Topic Chat' started by khan, May 23, 2007.

  1. khan
    OP

    khan GBAtemp Maniac

    Member
    1,320
    0
    Mar 17, 2003
    Pakistan
    Hi all,

    In my free time, I am trying to make a professional looking website on which I would like to display date with message i.e. good morning/afternoon/evening or night.

    I have found a very basic php script however I would really appreciate if someone could expand it so it prints out message along side the side as mentioned above. (BTW I have tried google to no avail)

    [/color]

    Thanks
     
  2. Kyuzumaki

    Kyuzumaki GBAtemp Regular

    Member
    251
    2
    Dec 24, 2006
    i don't have time to check the syntax costello will probably know but you just need a few if's. time() is a number indicating how many seconds have passed since midnight

    so something like
    //before 12noon
    if(time()43200 & time()64800 & time()75600){echo("Good night")}
     
  3. WishCow

    WishCow Advanced Member

    Newcomer
    85
    0
    Jul 24, 2006
    Hungary
    date('H'); returns the hour of the day, so you can do ifs:

    if (date('H') > 12) {
    echo("It's past twelve");
    }
     
  4. FrozenOne23

    FrozenOne23 GBAtemp Regular

    Member
    174
    0
    Sep 23, 2006
    Netherlands
    Uhm, time() is a function to display the seconds since January 1 1970 00:00:00 GMT
     
  5. Kyuzumaki

    Kyuzumaki GBAtemp Regular

    Member
    251
    2
    Dec 24, 2006
    ooo lol not used time() in php yet i assumed it was the same.
     
  6. Sinkhead

    Sinkhead yay p1ngpong.

    Former Staff
    3,692
    0
    Nov 22, 2006
    Across the pond
    To print a message in PHP use
    CODE
    So in your example you would use
    CODE

    I made a sample script here. Oh, and by the way, PHP uses the server's time so things get a little funky when timezones are brought in. You need to collect the time offset from server time from the user then store it somewhere and when the time is needed the difference should be calculated from server time. But that's only if you want to be clever.
    - Sam
     
  7. khan
    OP

    khan GBAtemp Maniac

    Member
    1,320
    0
    Mar 17, 2003
    Pakistan
    Thank you all for your suggestions/help.

    I am now working on a search engine which works as I wanted to however when there are more than 1 matching results then it still produces 1 single table display just 1 output result.

    I was wondering if some kind soul could help me out here, I just want php page to display a separate table with product details for every result it finds( i.e. if 2 products match search string then I would like 2 tables).

    Thanks in advance
     
  8. Kasoz

    Kasoz Advanced Member

    Newcomer
    97
    0
    May 16, 2007
    Netherlands
    You definetly need to learn some more PHP, this is really basic, and you can learn all these kind of things from a good book anyway, you only fetch 1 row, instead of multiple rows

     
  9. khan
    OP

    khan GBAtemp Maniac

    Member
    1,320
    0
    Mar 17, 2003
    Pakistan
    Thanks alot Kasoz for your help. It works