Jump to content

Search the Community

Showing results for tags 'concatenation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I have an array with data that looks like this: 01 | organization_1 | email_A | publication_A1 | pubID_A1 02 | organization_1 | email_A | publication_A2 | pubID_A2 03 | organization_1 | email_A | publication_A3 | pubID_A3 04 | organization_2 | email_B | publication_B1 | pubID_B1 05 | organization_2 | email_B | publication_B2 | pubID_B2 06 | organization_3 | email_C | publication_C1 | pubID_C1 07 | organization_4 | email_D | publication_D1 | pubID_D1 08 | organization_4 | email_D | publication_D2 | pubID_D2 The array is structured like this: array('org' => organization_x, 'email' => email_x, 'title' => publication_x, 'pub_id' => pubID_x) What I need to do is output this array so that it displays as individual email messages with a submit button after each. A person viewing this page would review the displayed message and he or she would have the option to click submit to send a particular message to the appropriate email. Here's the initial display I need to create: <!-- Message #1 --> <form> <input type="hidden" name="pub_ids" value="pubID_A1;pubID_A2;pubID_A3"> <input type="hidden" name="recipient" value="email_A"> <input type="hidden" name="organization" value="organization_1"> <!-- start on-screen text display --> To: email_A Your account contains the following publication titles: * publication_A1 * publication_A2 * publication_A3 You can edit these publications after logging into our system. Your email address, email_A, serves as your username. Thanks! <!-- end on-screen text display --> <input type="submit" name="submit" value="submit"> </form> <!-- Message #2 --> <form> <input type="hidden" name="pub_ids" value="pubID_B1;pubID_B2"> <input type="hidden" name="recipient" value="email_B"> <input type="hidden" name="organization" value="organization_2"> <!-- start on-screen text display --> To: email_B Your account contains the following publications: * publication_B1 * publication_B2 You can edit these publications after logging into our system. Your email address, email_B, serves as your username. Thanks! <!-- end on-screen text display --> <input type="submit" name="submit" value="submit"> </form> ...and on until all of the items in the array have been processed. I've tried some version of the following code for too long now. The idea is to loop through each item, concatenating the pub_id and title data into text strings to be passed through the form or shown on screen as needed. When the script hits a new organization name, it should put all the pieces together and then get started on the next organizaton's email message. The Code: $current_org = ''; $pub_ids = ''; $titles = ''; foreach ($array AS $value) { $pub_ids .= $value['pub_id'] . ';'; $titles .= '* ' . $value['title'] . '<br />'; if ($current_org != $value['org']) { echo '<form>'; echo '<input type="hidden" name="pub_ids" value="' . $pub_ids . '">'; echo '<input type="hidden" name="recipient" value="' . $value['email'] . '">'; echo '<input type="hidden" name="organization" value="' . $value['org'] . '">'; echo 'To: ' . $value['email']; echo '<br /><br />'; echo 'Your account contains the following publication titles:'; echo '<blockquote>'; echo $titles; echo '</blockquote>'; echo 'You can edit these publications after logging into our system. Your email address, ' . $value['email'] . ', serves as your username.'; echo '<br /><br />'; echo 'Thanks!'; echo '<input type="submit" name="submit" value="submit">'; echo '</form>'; echo '<br /><br />'; $pub_ids = ''; $titles = ''; $current_org = $value['org']; } } The Problem: The problem seems to be the first organization with more than one publication only gets one publication listed out. Then the next organization gets the last org's publication listed as well as their own. Then the rest are thrown off. Thinking this has something to do with my "if ($current_org != $value['org'])". Since $current_org starts off as NULL the first loop will never be set to $value['org'], so I get one loop through that gives me a pub_id, a title, and an email message -- then the old_org "changes" from NULL to the first $value['org'] value and the loop starts over again. I think this is what is going on. I can't figure out how to fix this though. Where/how would I check to see if the org value has changed? Any insight into this problem is much appreciated!
×
×
  • 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.