Some help with mysql_query - Screen output works, mail() not

Discussion in 'Programming' started by HolyMan, Sep 17, 2004.

  1. #1
    Hi All,

    Having a small problem with inputing some info into the php mail() function.

    What I have at the moment is
    $edquery = "SELECT institute, 
                            degree, 
                            subject, 
                            year 
                                from jobs_r_education, 
                                        jobs_degree, 
                                        jobs_subject 
                                    WHERE jobs_r_education.fk_degree = jobs_degree.id 
                                    AND jobs_r_education.fk_subject = jobs_subject.id 
                                    AND rid = '$rid' 
                                        ORDER BY year";
            $result = mysql_db_query($database, $edquery, $connection) or die ("Error in query: $edquery. " . mysql_error());
                if(mysql_num_rows($result) > 0){
                    while (list($institute, $degree, $subject, $year ) = mysql_fetch_row($result)){
    $education = "Institute: $institute,<ul>Degree: $degree,<br>Subject: $subject,<br>Year Completed: $year</ul>";
    echo "$education";
                    }
    						}
    Code (markup):
    This works like a bomb and the "echo "$education"; " outputs all returned responses to the screen perfectly

    However, when $education is included in the message part of mail(), only the last record is inserted into the mail.

    Any help greatly appreciated.......

    PS....my php knowledge is relatively light, so please be gentle


    Cheers
     
    HolyMan, Sep 17, 2004 IP
  2. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You're not building upon $education.

    You're setting it anew each time.

    Try $education .=

    That will deliver what you want.

    echo looks OK because you're outputting each result but not correctly assigning the results to $education.

    http://www.php.net/manual/en/language.operators.assignment.php
    php.net is your friend.

    - Bob Archer
    http://www.tropicrentals.com - Vacation Rentals Online.
     
    rvarcher, Sep 17, 2004 IP
  3. HolyMan

    HolyMan Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Brilliant..... Thanks

    Works well for the mail() function.......
     
    HolyMan, Sep 20, 2004 IP