Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Search Members By Birthday

  1. #11
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The type is 'date' and default it '0000-00-00', does that help?

  2. #12
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Then you would want something like this (for the form that is):

    Code:
    <form action="search.php" method="POST">
    Brithday Month: <select name="month">
      <option>Select A Month</option>
      <option value="01">January</option>
      <option value="02">February</option>
      <option value="03">March</option>
      <option value="04">April</option>
      <option value="05">May</option>
      <option value="06">June</option>
      <option value="07">July</option>
      <option value="08">August</option>
      <option value="09">September</option>
      <option value="10">October</option>
      <option value="11">November</option>
      <option value="12">December</option>
    </select>
    <input type="submit" value="Search">
    </form>
    and this for search.php:

    Code:
    <?php
    $month = $_REQUEST['month'];
    
    $info = mysql_query("SELECT * FROM `table` WHERE `birthday` LIKE '&#37;$month%'");
    
    /* Rest of php code here */
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #13
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmmm it's spitting out an error... I think I might have put the code wrong somewhere...
    PHP Code:
    <?php

    /* connect to the mysql database and use a query to get the members info */

    include 'library/config.php';
    include 
    'library/opendb.php';
    //navigation

    include("nav.php");

    //assign the bday variable.
    $month $_REQUEST['month'];

    //birthday search
    $info mysql_query("SELECT * FROM `tblmembers` WHERE `DateOfBirth` LIKE '%$month%'");

    $info mysql_query($sql);

    echo 
    '<table border="1" cellpadding="3" cellspacing="1">
      <tr valign="top">
        <td>First Name</td>
        <td>Last Name</td>
        <td>DateOfBirth</td>
        <td>Last Login</td>
      </tr>'
    ;

    if (
    mysql_num_rows($info) < 1) {
    echo 
    '<tr valign="top">
      <td colspan="4">There are no members that match the query. Please go back and try again</td>
        </tr>'
    ;
    }

    else {
       while (
    $qry mysql_fetch_array($info)) {

    //create the layout
    ?>
    <link href="cs_style.css" rel="stylesheet" type="text/css" />

      <tr valign="top">
        <td><?php echo $qry['FirstName']; ?></td>
        <td><?php echo $qry['LastName']; ?></td>
        <td><?php echo $qry['DateOfBirth']; ?></td>
        <td><?php echo $qry['State']; ?></td>
      </tr>
    <?php
       
    }
    }

    echo 
    '</table>';
    ?>

  4. #14
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    What's the error, that way we could pinpoint it in the code.

    EDIT: Nevermind, in your code above, you have 2 mysql_query's. Get rid of the second one (or the one that looks like this):

    Code:
    $info = mysql_query($sql);
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #15
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm slow sorry... Ok all worked! But I lost my date/time format... Any ideas?
    PHP Code:
    echo $qry['loginDateTime'];
    echo(
    $qry['loginDateTime']?date('d/m/Y H:i:s'strtotime($qry['loginDateTime'])):'unknown'

  6. #16
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    To get your date/time format back, you could probably use the following:

    Code:
    echo date('d/m/Y H:i:s', strtotime($qry['DateOfBirth']));
    in place of the part in red below:

    Code:
    <?php
    
    /* connect to the mysql database and use a query to get the members info */
    
    include 'library/config.php';
    include 'library/opendb.php';
    //navigation
    
    include("nav.php");
    
    //assign the bday variable.
    $month = $_REQUEST['month'];
    
    //birthday search
    $info = mysql_query("SELECT * FROM `tblmembers` WHERE `DateOfBirth` LIKE '&#37;$month%'");
    
    $info = mysql_query($sql);
    
    echo '<table border="1" cellpadding="3" cellspacing="1">
      <tr valign="top">
        <td>First Name</td>
        <td>Last Name</td>
        <td>DateOfBirth</td>
        <td>Last Login</td>
      </tr>';
    
    if (mysql_num_rows($info) < 1) {
    echo '<tr valign="top">
      <td colspan="4">There are no members that match the query. Please go back and try again</td>
        </tr>';
    }
    
    else {
       while ($qry = mysql_fetch_array($info)) {
    
    //create the layout
    ?>
    <link href="cs_style.css" rel="stylesheet" type="text/css" />
    
      <tr valign="top">
        <td><?php echo $qry['FirstName']; ?></td>
        <td><?php echo $qry['LastName']; ?></td>
        <td><?php echo $qry['DateOfBirth']; ?></td>
        <td><?php echo $qry['State']; ?></td>
      </tr>
    <?php
       }
    }
    
    echo '</table>';
    ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #17
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I don't know what I am doing today! My posts aren't posting properly or something... What it does is sort them, but it adds both the month and the day as the result. So say I search February, it adds Member 1, 12/03/1980 and also Member 2, 27/12/1973... See what it's doing any idea why?

  8. #18
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I get an error message on people that were born beofre 1970... That's wierd, surely you can display birthdays prior to that?

    Warning: date(): Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in \birthdaysearch.php on line 41

  9. #19
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Taken from the php.net website:

    The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). However, before PHP 5.1.0 this range was limited from 01-01-1970 to 19-01-2038 on some systems (e.g. Windows).
    That's for version 5.1.0 and later. What version are you running and what OS is it? That could be the reason why you are getting that error.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #20
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ahhhhh damn it's a Windows server... So is there no workaround?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •