Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6585989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:44:01+00:00 2026-05-25T16:44:01+00:00

//First I’m assigning a $variable ($emailzipmatch) to query a database table called(repzipcodes) and having

  • 0

//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.

// CODE WORKS BELOW

$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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:44:02+00:00Added an answer on May 25, 2026 at 4:44 pm

    I think I know what you are going for here. I have done something similar before where I needed to keep a record for a while so I gave each search result an id on output and placed them in separate rows of a table along with a time stamp so it could be cleaned up at a later time or if you wish to search by time (mysql has a timestamp of it’s own also but that’s another thing to look in to if you haven’t already)

    So to make a ‘log table’ for example you might want to design something that works like the following:

    <?php
    
    $search_id = md5(uniqid()).rand(100,999); //// MAKE AN ID FOR THE SEARCH;
    $timestamp = time(); // IN CASE YOU WANT TO CLEAN UP AT A LATER DATE, MUST BE AN INTEGER IN MYSQL (so you can use a less than $timestamp in the delete query)
    
    $emailzipmatch = mysql_query("SELECT * FROM repzipcodes WHERE RepZipCode = $CustomerZipMatch GROUP BY RepId HAVING COUNT(1) <= 3") or die(mysql_error()); // if you are just wanting to limit the results look at LIMIT in a mysql tutorial somewhere. 
    
    $recipients = array();
    while($row = mysql_fetch_array($emailzipmatch)) 
    { 
    //// THE REST OF YOUR CODE HERE (and at the end of the while loop insert in to a table, in your case 'sentemail')
    
    mysql_query("INSERT INTO sentemail (search_id, rep_email, rep_id, zip_code, timestamp) VALUES ('$search_id', '{$row['RepEmail']}', '{$row['RepId']}', $CustomerZipMatch, $timestamp);") or die(mysql_error()); // or what ever details you are after
    }
    
    ?>
    

    This should leave you with a reference table that you can search for by different criteria. Not the most perfect way of doing it but it will get the job done.

    Hope that gives you a different perspective on it 🙂

    In regards to “due to my lack of experience with PHP”: As you develop your skills, and you will I’m sure, take some time to look at Object Oriented PHP in the future. For more server heavy or complicated things it can be worth knowing. I’m saying this to you now because I wish someone had told me earlier.

    Good luck.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, let's get the security considerations out of the way. I'm using simple authentication
First off, I am using Windows XP. I have multiple hard drives and it
First off, I understand the reasons why an interface or abstract class (in the
First off if you're unaware, samba or smb == Windows file sharing, \\computer\share etc.
First of all, I know how to build a Java application. But I have
First off, there's a bit of background to this issue available on my blog:
First off: I'm using a rather obscure implementation of javascript embedded as a scripting
First let me say that I really feel directionless on this question. I am
First off, I'm working on an app that's written such that some of your
First of all, I don't need a textual comparison so Beyond Compare doesn't do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.