Insert row mysql database to a email

Discussion in 'PHP' started by webboy, Jul 10, 2007.

  1. #1
    HI all very newbe question here


    I have a small mysql database and wish to send a email to a person every time they fill out my contact page aslo adding a 3 rows from the DB

    I have managed to send the email with success and also connected to the database but having problems outputting MSQL select query in the message body within loop.

    how would I add this within the text body of the email (as you can see the coding is a bit wrong)

    would it better to define the $row as a variable first as I tried that but still could not get the correct syntax for the while statement
    i guess i dont use echo as that put it to the screen

    $message4= " blab blab “ . while ($row = mysql_fetch_array($result))
    {

    $row['Company'] . “<br> “ .
    $row['description'] .””;

    }

    I am really puzzled
     
    webboy, Jul 10, 2007 IP
  2. Bartuc

    Bartuc Active Member

    Messages:
    120
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    #2
    i didn't understand what you are trying to do. if u can explain clearly, i may help.
     
    Bartuc, Jul 10, 2007 IP
  3. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #3
    That is some clever PHP there.

    
    $message4= " blab blab <br>“;
    while ($row = mysql_fetch_[b]assoc[/b]($result))
    {
    
    $message4 .= $row['Company'] . “<br> “ .
    $message4 .=  $row['description'] . "<br>";
    
    } 
    
    Code (markup):
    Also the hash is case sensitive. "Company" needs to have an upper case C in the table structure as well.
     
    KalvinB, Jul 10, 2007 IP
  4. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Ok lets trying again

    I have a database with the fileds company , name , url

    I have a conact us page in PHP which when a person clicks it will call the php file to send a email

    the file should select the company , name , url from the database and insert it in to the a email to reply back to the person.


    Problem..

    I do not know how to insert the result from the select statement into the email as i cannot get the correct syntax
    eg

    the person would see a email

    Have a nice day

    <company> <name> <url> (Row 1)
    <company> <name> <url> (Row 2)
    <company> <name> <url> (Row 3)
     
    webboy, Jul 10, 2007 IP
  5. KalvinB

    KalvinB Peon

    Messages:
    2,787
    Likes Received:
    78
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What I posted will work as long as the hash is using the right table field names. You then just need to figure out what HTML to put into the string along with the row values.
     
    KalvinB, Jul 10, 2007 IP
    bogart likes this.
  6. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ok !!! MAGIC

    before i say where do i send the money , its repating the whole 2 3 time any ideas why

    for each row , it should repate the fileds right
     
    webboy, Jul 10, 2007 IP
  7. Brewster

    Brewster Active Member

    Messages:
    489
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    60
    #7
    Try this:

    $message4= " blab blab <br>";
    while ($row = mysql_fetch_assoc($result))
    {
    
    $message4 .= $row['Company'] . "<br /> " .$row['description'] . "<br>";
    
    }
    PHP:
    Brew
     
    Brewster, Jul 10, 2007 IP
  8. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    YOU ARE DA MAN!!!!

    I AM SO HAPPY IF YOU COULD SEE ME NOW !!!! Back spinning like the GICO green thing...
     
    webboy, Jul 10, 2007 IP
  9. webboy

    webboy Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Opps Thank You
     
    webboy, Jul 10, 2007 IP