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 7641735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:59:58+00:00 2026-05-31T08:59:58+00:00

I have a form that displays contact email addresses in text boxes, and drop

  • 0

I have a form that displays contact email addresses in text boxes, and drop down selections for titles for those corresponding emails.

TitleSelect1 Email1
TitleSelect2 Email2 ….

the emails have a title_id set, and the select list selects the existing Title. This works fine for the first contact, but the rest will only display the email address, the title dropdown is empty.

<?php

while ($row2 = mysql_fetch_array($Contact_list)) {
    ?>
<tr>
    <td align="right"><select id="Contacts_title" name="Contacts_title[]">
        <?

        while ($row3 = mysql_fetch_array($title_list)) { //put the contact titles into an array

            if ($row3['title_id'] == $row2['title_id']) {
                ?>
                <option value="<? echo $row3['title_id'] ?>" selected="true"><? echo $row3['title'] ?>!</option>';
                <?
            }

            else {
                ?>
                <option value="<? echo $row3['title_id'] ?>"><? echo $row3['title'] ?> </option>';
                <?
            }
        }

        ?>
    </select>
    </td>
    <td align="left"><input type="text" id="Contacts" name="Contacts[]" value="<? echo $row2['email'] ?>"/></td>
</tr>
<?
    $count++;
} 
  • 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-31T08:59:59+00:00Added an answer on May 31, 2026 at 8:59 am

    mysql_fetch_array() only goes through the results of a given query once. Since you’re not executing the title_list query every time though your contact list loop, it’s still at the end of the query results when you start every iteration after the first.

    What you need to do is take all the results from your title_list query, put them into an array, and iterate over that for each of your contacts.


    Here’s a general example of how you’d do this (with extraneous bits trimmed out):

    $contact_list = //some query
    $title_list = //some query
    
    $titles = array();
    while($title_ar = mysql_fetch_array($title_list)) {
      $titles[] = $title_ar;
    }
    
    while($contact_ar = mysql_fetch_array($contact_list)) {
        // some stuff
        foreach($titles as $title) {
            // do something with each title
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contact form that has a drop-down for referral source. If Magazine
I have a page that has a Contact Form slide down when a link
I have one contact form, that send the email to one of Address selected
I have a form that consists of: 3 text boxes (first two are required
I have an application that consists of two forms. One form displays data returned
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN
I have a Windows Form that displays several DataGridViews in the following layout: (No
I have a contact form that checks if some field is empty when you
I have a form that validates using jquery. The form's id is contact and
I have a form <form method=post action=sendmail.php name=Email form> Message ID <input type=text name=message_id

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.