0

I am attempting to use two queries to set up multiple dropdown menus per doctor. So far this is working, however it unfortunately pulls only the item.

I would like to have all of the 'expertises' available within the dropdown (and the expertise IDs as the option values).

I have set up the below while loop, however I have been unsuccessful in producing a dropdown for each Client_ID.

The first query (below) pulls the client ID from the area

$client_id = $_GET['doc_id'];
$physician_id_expertise = $client_id;

$doctor_query = 'SELECT * ';
$doctor_query.= 'FROM `primarycare_expertise` ';
$doctor_query.= 'WHERE `physician_id`=' . $client_id . ' ';
$doctor_result = mysql_unbuffered_query( $doctor_query );

The while loop incorporates the second query, which sets up the dropdown (pulling in all of the 'expertise' values).

while ($doctor_row = mysql_fetch_array( $doctor_result ))
{
    echo "<select name='doc_id_expertise_" . $doctor_row['pe_id'] . "' id='doc_id_expertise_" . $doctor_row['pe_id'] . "'>";

    $expert_query = 'SELECT * FROM `expertise` ';
    $expert_result = mysql_unbuffered_query( $expert_query );

    while ($expert_row = mysql_fetch_array( $expert_result )){
        if($doctor_row['expertise_id'] == $expert_row['expertise_id'])
        {
            $selected = "selected";
        } else {
            $selected = "";
        }
        echo "<option $selected value=" . $expert_row['expertise_id'] . ">" . $expert_row['expertise'] . "</option>";
    }

    echo "</select>";
    echo "<br />";
}

If any of you could help me out, I would be very appreciative! Thank you for your time!

0

2 Answers 2

1

You are sending new query while iterating through unbuffered result of previous query. This does not work. Try using mysql_query instead of mysql_unbuffered_query for the first query like this:

$doctor_result = mysql_query (
    "SELECT * FROM primarycare_expertise WHERE physician_id='$client_id'");

For subsequent queries you could still use mysql_unbuffered_query because they do not overlap.

See the following page for details.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, this worked perfectly. I've been using 'unbuffered' for most of my queries, forgot to change it for this one. Thank you again.
0

The mysql package is deprecated BTW. Consider adopting to the mysqli extension instead.

http://www.php.net/manual/en/book.mysqli.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.