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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:49:17+00:00 2026-06-01T14:49:17+00:00

I have a webpage written in HTML. I have a dropdown list that is

  • 0

I have a webpage written in HTML. I have a dropdown list that is populated by a database utilizing a MySQL query:

<SELECT NAME = "Participant" STYLE = "WIDTH: 187" TITLE="Begin typing participant last name for fast searching." required>
<OPTION SELECTED VALUE = "">Select Participant...</OPTION>
<?PHP
    $allParticipants = getall_participants();
    foreach($allParticipants as &$value) {
        $dt = date('Y-m-d'); 
        $val = $value->get_id();
        $optval = $dt.$val;
        echo "<OPTION VALUE='",$optval,"'>";
        echo $value->get_first_name()," ",$value->get_last_name();
        echo "</OPTION>";
    }
?>
</SELECT>

The getall_participants() looks like:

function getall_participants () {
connect();
$query = "SELECT * FROM dbParticipants ORDER BY last_name";
$result = mysql_query ($query);
$theParticipant = array();
while ($result_row = mysql_fetch_assoc($result)) {
    $theParticipant = new Participant($result_row['last_name'], 
                      $result_row['first_name'], $result_row['address']);
    $theParticipants[] = $theParticipant;
}
mysql_close();
return $theParticipants;
}

And on this same page I have a textbox that is pre-filled-in by another database:

<?php
    $dt = date('Y-m-d'); 
    $participants = getall_dbParticipantEntry_byDate($dt);
    foreach($participants as &$value) {
        $a = $a.$value.", ";
    }
    echo "<INPUT TYPE='text' NAME='Participants' STYLE='WIDTH:50px;' TITLE='Participants' ";
    echo "VALUE='[", $a.' ', "]'/>";
?>

That getall_dbParticipantEntry_byDate($date) looks like:

function getall_dbParticipantEntry_byDate($date) {
connect();
$query = 'SELECT * FROM dbParticipantEntry WHERE date = "'.$date.'"';
$result = mysql_query ($query);
$theParticipantEntry = array();
while ($result_row = mysql_fetch_assoc($result)) {
    $theParticipantEntry = new ParticipantEntry($result_row['date'], $result_row['id'], $result_row['call_time'],
    $result_row['result'], $result_row['notes']);
    $theParticipantEntries[] = $theParticipantEntry->get_id();
}
mysql_close();
return $theParticipantEntries;
}

However, while both of these functions work fine individually, when they’re both on the same webpage (like I meant them to be), only the one that comes first runs. I tested this by switching them in and out. They both complete their designated tasks, but only when alone on the page.
How can I get them both to run and populate their respective fields?

Thanks so much.

  • 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-06-01T14:49:18+00:00Added an answer on June 1, 2026 at 2:49 pm

    Try the following order:

    1. Connect to mySQL server

    2. Do task 1

    3. Do task 2

    4. Close Connection

    For me it looks, like you have closed the mysqlconnection, before you do task2.

    Edit:

    Maybe you can do it like that?

    function f1 ()
    {
        $res = mysql_connect(...);
    
        // .. do some queries ..
        mysql_query($sql, $res); 
    
        mysql_close($res ) 
    }
    
    function f2 ()
    {
        $res = mysql_connect(...);
    
        // .. do some queries ..
        mysql_query($sql, $res); 
    
        mysql_close($res ) 
    }
    

    Edit:

    From php.net:

    Be careful when using multiple links to connect to same database (with same username). Unless you specify explicitly in mysql_connect() to create a new link, it will return an already open link. If that would be closed by mysql_close(), it will also (obviously) close the other connection, since the link is the same.
    Had lot of trouble figuring it out, since in <=4.3.6 there was a bug which didn’t close the connection, but after the patch to >=4.3.7, all my application broke down because of a single script that did this.

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

Sidebar

Related Questions

Basically I have a HTML option box written like so: <span>Design </span><select name=style> <option
I have written a program that uses qhttp to get a webpage. This works
I have a webpage that displays a very large list of data. Since this
I have written a database connection - <html xmlns=http://www.w3.org/1999/xhtml > <head id=Head2 runat=server> <title>SQL
I have a web page that i have written in mainly HTML. When I
I have a webpage that redirects to another webpage like this: http://www.myOtherServer.com/Sponsor.php?RedirectPage=http://mylink.com/whereIwasgoingtogo.html Then the
I have a webpage that I don't have the ability to change the underlying
I have a webpage that activates a print job on a printer. This works
I have written a web scraping program to go to a list of pages
I have a web page written in pure HTML (with a .html extension). Whenever

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.