Monks, This should be easy but I'm confused. I'm searching the database for records of jobs that are posted today. Then based on the job type, I do another loop through a different database to find 5 random jobs that match that type. I want to set these to a variable, then print all 5 in an email. I don't know how to create a list of all 5. The code below obviously only prints the first record in the email. How do I stuff the $my_jobs var into a list so I can print all 5 after the second loop is done?
$SQL = "Select * from database where active='yes' AND (TO_DAYS(NOW())- +TO_DAYS(dateadded) < 1)"; #check for records created today &Do_SQL; while ($pointer = $sth->fetchrow_hashref) { $jobtype = $pointer->{'jobtype'}; $toemail = $pointer->{'email'}; $SQL3 = "Select * from database where jobtype='$jobtype' A +ND active='yes' ORDER BY RAND() LIMIT 5"; &Do_SQL3; while ($pointer3 = $sth3->fetchrow_hashref) { $contact= $pointer3->{'contact'}; $jobnum= $pointer3->{'jobnum'}; $picture = $pointer3->{'picture'}; $my_job = "<tr><td style=\"width:60px;padding:0;\">$pictur +e - <a href=\"/get-job.pl?jobnum=$jobnum\">$contact</a></td></tr>"; } } open (MAILHTML, "|$sendmail $toemail") || die "Can't open $sendmail!\n +"; print MAILHTML "From: Admin <admin\@admin.com>\n"; print MAILHTML "Reply-to: Admin <admin\@admin.com>\n"; print MAILHTML "To: $toemail\n"; print MAILHTML "Subject: Recommended Jobs\n"; print MAILHTML "Content-Type: text/html\n"; print MAILHTML "$my_job"; close (MAILHTML);

In reply to More loop issues by htmanning

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.