Jump to content

Putting Array Results into a table


WileyWeb

Recommended Posts

//First I'm assigning a $variable ($emailzipmatch) to query a database table called(repzipcodes) and having it pull and display 1 to 3 records based on matching up a customer's zip code (RepZipCode = $CustomerZipMatch) with 1 to 3 other people (GROUP BY RepId HAVING COUNT(1) <= 3") that want that customer's information from that particular zip code. <This code works fine>

 

// CODE WORKS BELOW

<?php
    $emailzipmatch = mysql_query("SELECT * FROM repzipcodes WHERE RepZipCode = $CustomerZipMatch GROUP BY RepId HAVING COUNT(1) <= 3") or die(mysql_error());

    $recipients = array();
    while($row = mysql_fetch_array($emailzipmatch)) 
    { 
    $recipients[] = $row['RepEmail'];

    echo "Agent's Email Address: ";

    echo 'font color="#FF7600"',$row['RepEmail'], '/font';

    echo '<br />'; 

    echo "Rep's ID: "; 
    echo '<br />';
    echo 'font color="#FF7600"',$row['RepId'], '/font';
    echo '<br />';
    echo 'hr align="left" width="50%" size="2" /';
    }


//MY PROBLEM BELOW

// For the NEXT step of the process above I would take $row['RepEmail'] and $row['RepId'] which can have 1 to 3 results and assign the 1 to 3 results a new $variable so it can be inserted into a different db table so I can track the results of the query ($emailzipmatch = ) from the top of the page: ie..

    <New Variable>   <Listed from above>
    $SentRepId 0   = RepId (results from above echo area)
    $SentRepId 1   = RepId (results from above echo area)
    $SentRepId 2   = RepId (results from above echo area)


// Below I'd like to insert the above results into a new database

    $?Variable??? = mysql_query("INSERT INTO sentemail 
   (SentRepId0, SentRepId1, SentRepId2,SentDateTime
   ) VALUES (
   '$_SESSION[RepId]', // ?????
   '$_SESSION[RepId]', // ?????
   '$_SESSION[RepId]', // ?????
    NOW()
     )") or die(mysql_error());

 

Thank ahead of time for any help you guys can give me. Please respond with ANY question if my coding or request isn't clear or if I've been confusing due to my lack of experience with PHP and MySQL.

 

 

MOD EDIT: code tags added.

Link to comment
https://forums.phpfreaks.com/topic/247233-putting-array-results-into-a-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.