Jump to content

MrLarkins.com

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Posts posted by MrLarkins.com

  1. hmm, i don't see where it is...you look...[code]<?php
    //----------------------------
    // Require
    //----------------------------
    require "forums/conf_global.php"; //because this file will not be located in the forums directory.

    //-------------------------------
    // Connect To MySQL
    //-------------------------------
    mysql_connect($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']) or die(mysql_error());
    mysql_select_db($INFO['sql_database']) or die(mysql_error());


    $define_country = array("u"=>"United States","e"=>"England","c"=>"Canada","m"=>"Mexico","a"=>"Aruba","o"=>"Other");
    $define_state = array("AL"=>"Alabama","AK"=>"Alaska","AZ"=>"Arizona","AR"=>"Arkansas","CA"=>"California","CO"=>"Colorado","CT"=>"Connecticut","DE"=>"Delaware","DC"=>"District of Columbia","FL"=>"Florida","GA"=>"Georgia","HI"=>"Hawaii","ID"=>"Idaho","IL"=>"Illinois","IN"=>"Indiana","IA"=>"Iowa","KS"=>"Kansas","KY"=>"Kentucky","LA"=>"Louisiana","ME"=>"Maine","MH"=>"Marshall Islands","MD"=>"Maryland","MA"=>"Massachusetts","MI"=>"Michigan","MN"=>"Minnesota","MS"=>"Mississippi","MO"=>"Missouri","MT"=>"Montana","NE"=>"Nebraska","NV"=>"Nevada","NH"=>"New Hampshire","NJ"=>"New Jersey","NM"=>"New Mexico","NY"=>"New York","NC"=>"North Carolina","ND"=>"North Dakota","MP"=>"Northern Mariana Islands","OH"=>"Ohio","OK"=>"Oklahoma","OR"=>"Oregon","PA"=>"Pennsylvania","PR"=>"Puerto Rico","RI"=>"Rhode Island","SC"=>"South Carolina","SD"=>"South Dakota","TN"=>"Tennessee","TX"=>"Texas","UT"=>"Utah","VT"=>"Vermont","VI"=>"Virgin Islands","VA"=>"Virginia","WA"=>"Washington","WV"=>"West Virginia","WI"=>"Wisconsin","WY"=>"Wyoming","AB"=>"Alberta","BC"=>"British Columbia","MB"=>"Manitoba","NB"=>"New Brunswick","NL"=>"Newfoundland and Labrador","NT"=>"Northwest Territories","NS"=>"Nova Scotia","NU"=>"Nunavut","ON"=>"Ontario","PE"=>"Prince Edward Island","QC"=>"Quebec","SK"=>"Saskatchewan","YT"=>"Yukon","OO"=>"Other");
    $define_character = array("m"=>"Medic","g"=>"Gunner","r"=>"Rifleman","s"=>"Sniper","e"=>"Engineer");

    //Start HTML Table
    print('<table cellspacing=0 cellpadding=0 width=100%>');
    //-----------------------------------
    //Get Info
    //-----------------------------------
    $main_result = mysql_query("SELECT m.id, m.name, m.email, m.joined, m.bday_day, m.bday_month,
        m.bday_year, x.icq_number, c.field_1, c.field_2, c.field_3, c.field_4
    FROM ibf_members AS m
    INNER JOIN ibf_member_extra AS x ON m.id = x.id
    INNER JOIN ibf_pfields_content AS c ON m.id = c.member_id
    WHERE mgroup=7
    ORDER BY id");
    while($main = mysql_fetch_array($main_result)) { //while you have records available from the SELECT query
        $id = $main['id'];
        $name = $main['name'];
        $email = $main['email'];
        $join_date = $main['joined'];
        $bday_day = $main['bday_day'];     
        $bday_month = $main['bday_month'];
        $bday_year = $main['bday_year'];   
        $icq = $main['icq_number'];
        $stats = $main['field_1'];
        $character = $main['field_2'];
        $country = $main['field_3'];
        $state = $main['field_4'];

    function getAge ($bday, $bmon, $byr) {
        $ynow = date('Y');
       
        $age = $ynow - $byr;
            // format birth month and day as "0901"
        $bmd = sprintf ('%02d%02d', $bmon, $bday);
            // format today monthand day in same way
        $mdnow = date('md');
       
        if ($bmd > $mdnow) $age -= 1;  // sub 1 from age if not there yet
       
        return $age;
    }

    // call the function to get the age
    $age = getAge ($bday_day, $bday_month, $bday_year);

    echo $age;


    echo ("<tr><td>$name </td><td>JOINED $join_date</td><td><img src='images/flags/$define_country[$country].gif' border=1 alt='$define_country[$country]'> <img src='images/flags/$define_state[$state].gif' border=1 alt='$define_state[$state]'></td><td><a href='http://web.icq.com/whitepages/add_me?uin=$icq_number&action=add'><font size='-1'>$icq_number</font></a></td><td><a href='mailto:$email'><font size='-1'>Email</font></a></td><td>AGE $age</td><td><a href='$stats'><font size=-1><b><u>JO Stats</u></b></a></td><td>$define_character[$character]</td></tr>");
    }


    //Finish the HTML table
    print('</table>');

    ?>[/code]
  2. hey, that looks like a winner.  but it leaves me with two new problems


    1]  my birthday data is from seperate columns in the database.  how would i merge them to make it the necessary formatting for your code?

    2]  my birthday data is of the form YYYY for year, M for month, and D for day, when it needs to be (YYYY-MM-DD). i.e.  the 1st shows as '1' not '01' and August shows as '8' not '08'.  would i use a push to add the preceeding zeros? 
  3. ok, i
    $bday_day //birthday day
    $bday_month //birthday month
    $bday_year //birthday year
    $today = getdate();
    previously defined from a mysql grab i've done (the birthday stuff is in the database in columns bday_day, bday_month, bday_year)

    what i'd like to do is use this data to find out how old the person is and display it
  4. i tried this

    $main = mysql_query("SELECT m.id, m.name, m.email, m.joined, m.bday_day, m.bday_month,
        m.bday_year, x.icq_number, c.field_1, c.field_2, c.field_3, c.field_4
    FROM ibf_members AS m
    INNER JOIN ibf_member_extra AS x ON m.id = x.id
    INNER JOIN ibf_pfields_content AS c ON m.id = c.member_id
    WHERE mgroup=4
    ORDER BY id");
    while($main = mysql_fetch_array($main)){ //while you have records available from the SELECT query
    $id = $main['m.id'];
    $name = $main['m.name'];
    $email = $main['m.email'];
    $join_date = $main['m.joined'];
    $bday_day = $main['m.bday_day'];     
    $bday_month = $main['m.bday_month'];
    $bday_year = $main['m.bday_year'];   
    $icq = $main['x.icq_number'];
    $stats = $main['c.field_1'];
    $character = $main['c.field_2'];
    $country = $main['c.field_3'];
    $state = $main['c.field_4'];

    echo ("$id = $name = $email = $icq = $stats");

    i got 4 equal signs (nodata) and an error message referring to[code]while($main = mysql_fetch_array($main)){ //while you have records available from the SELECT query[/code]

  5. I have data from 3 different tables to join.

    table 1 has id, name, email
    table 2 has icq_number
    table 3 has field_1,field_2,field_3

    here is what i have so far:
    $main = mysql_query("SELECT id, name, email, joined, bday_day, bday_month, bday_year FROM ibf_members WHERE mgroup=4 ORDER BY id");
    while($main = mysql_fetch_array($main)){ //there are 5 members in this group
    $id = $main['id'];
    $name = $main['name'];
    $email = $main['email'];

    $icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE id = $id");
    $icq_number = $icq['icq_number'];

    $extra_two = mysql_query("SELECT field_1, field_2, field_3, field_4 FROM ibf_pfields_content WHERE member_id = $id");
    $stats = $extra_two['field_1'];
    $character = $extra_two['field_2'];
    $country = $extra_two['field_3'];

    //do some html stuff to display
    }

    this code is wrong, but i have no clue how to join data together.  please help.
  6. sorry, here is the full part

    $main = mysql_query("SELECT id, name, email FROM ibf_members WHERE mgroup=4 ORDER BY id");
    while($main = mysql_fetch_array($main)){ //while you have records available from the SELECT query
    $id = $main['id'];
    $name = $main['name'];
    $email = $main['email'];

    $icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE id = $id");
    $icq_number = $icq['icq_number'];

    //then do html to display results
    }
  7. while($main = mysql_fetch_array($main)){
    $id = $main['id'];
    $name = $main['name'];
    $email = $main['email'];

    $icq = mysql_query("SELECT icq_number FROM ibf_member_extra WHERE id = $id");
    $icq_number = $icq['icq_number'];

    //then do html to display results
    }

    my question is about the mysql query within the while(), is this possible, or is there a better way?
  8. [code]$main = mysql_query("SELECT id FROM ibf_members WHERE mgroup=4");
    $main = mysql_fetch_array($main);
    $id = $main['id'];[/code]

    here is my code.  I know for a fact that there are five entries in the database in column id where mgroup=4, however when i do
    [code]$count = count($id);
    print("$count");[/code]

    i get 1

    isn't $id an array here?  or did i do something wrong?
×
×
  • 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.