0

i have this code working well in file add a doctor (add_doctor.php):

    <form enctype="multipart/form-data" form action="add_doctor.php" method="post">
    <fieldset>

<p><font color="green"><b>Studii și Specializări:</b></font></p>
<p><b>Universitatea:</b> 
    <select name="universit"><option>Selectează</option>
    <?php // Retrieve all the university and add to the pull-down menu.
    $q = "SELECT adm_id, CONCAT_WS(' ', universitate) FROM adm ORDER BY universitate ASC";      
    $r = mysqli_query ($dbc, $q);
    if (mysqli_num_rows($r) > 0) {
        while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
            echo "<option value=\"$row[0]\"";
            // Check for stickyness:
            if (isset($_POST['universit']) && ($_POST['universit'] == $row[0]) ) echo ' selected="selected"';
            echo ">$row[1]</option>\n";
        }
    } else {
        echo '<option>Vă rugăm adăugați o Universitate prima dată.</option>';
    }
    mysqli_close($dbc); // Close the database connection.
    ?>
    </select>&nbsp;&nbsp;&nbsp;<a href="adm_universitate.php" target=_"blank">Adaugă</a><font color="red">&nbsp;*</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

but in file edit a doctor (edit_doctor.php) how can i insert code to select university from mysql table in dropdown list? here in my code bellow, i can view data from universitate field, but cannot change it. how can i add a dropdown list, like an example above to select other value?

// Retrieve the doctor's information:
$q = "SELECT universitate, numele, initiala_tatalui, prenumele, numele_anterior, sex, cnp, adresa_email, specialitate, specialitate2, an_abs_univ, seria_dipl_univ, nr_dipl_univ, first_name, user_id, data_adaugarii, first_name_mod, user_id_mod, stare, cod_parafa, data_modificarii FROM adm, medici, adm1 WHERE adm.adm_id=medici.adm_id AND adm1.adm1_id=medici.adm1_id AND medic_id=$id";        
$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the doctor's information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);

// Create the form:

echo '<form action="edit_doctor.php" method="post">
<fieldset>
<p><font color="green"><b>Studii și Specializări:</b></font></p>

<p>Universitatea: <input type="text" readonly name="universit" size="50" maxlength="50" value="' . $row[0] . '" />&nbsp;&nbsp;&nbsp;
...
</fieldset>
<p></p>
<p><div align="center"><input type="submit" name="submit" value="Modifică" /></p>
<input type="hidden" name="id" value="' . $id . '" />
</form>';

i have try this scenario: but i get error and doesn't work.

// Retrieve the doctor's information:
$q = "SELECT universitate, numele, initiala_tatalui, prenumele, numele_anterior, sex, cnp, adresa_email, specialitate, specialitate2, an_abs_univ, seria_dipl_univ, nr_dipl_univ, first_name, user_id, data_adaugarii, first_name_mod, user_id_mod, stare, cod_parafa, data_modificarii FROM adm, medici, adm1 WHERE adm.adm_id=medici.adm_id AND adm1.adm1_id=medici.adm1_id AND medic_id=$id";        
$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the doctor's information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);

// Create the form:

echo '<form action="edit_doctor.php" method="post">
<fieldset>
<p><font color="green"><b>Studii și Specializări:</b></font></p>

<p><b>Universitatea:</b> 
<select name="universit"><option>Selectează</option>
<?php // Retrieve all the artists and add to the pull-down menu.
$q = "SELECT adm_id, CONCAT_WS(' ', universitate) FROM adm ORDER BY universitate ASC";      
$r = mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) > 0) {
    while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
        echo "<option value=\"$row[0]\"";
        // Check for stickyness:
        if (isset($_POST['universit']) && ($_POST['universit'] == $row[0]) ) echo ' selected="selected"';
        echo ">$row[1]</option>\n";
    }
} else {
    echo '<option>Vă rugăm adăugați o Universitate prima dată.</option>';
}
mysqli_close($dbc); // Close the database connection.
?>
...
</fieldset>
<p></p>
<p><div align="center"><input type="submit" name="submit" value="Modifică" /></p>
<input type="hidden" name="id" value="' . $id . '" />
</form>';

in edit_doctor.php what i need is to retrieve all informations about doctor including university field from database (based on ID doctor), and i want it to change in same way like in add_doctor.php from a dropdown list (get it from database). in add_doctor.php was simple because i have not need to colect any data, just i insert a new doctor.

Thank's for help.

ok, from three weeks i work very hard to retrive doctors information, and modify if i want in my database. with your helps i didn't success. maybe it's simple bad syntax, so i decided to put here entire code from edit_doctor.php in romanian lang called edit_medic.php. this code is working, but i cannot change value from dropdown in Specialitate and Universitate (speciality and university in english). i get blank page, and i don't know why. please help to add dropdown to select new university/speciality if i want to change current value in my database. here is my code:

<?php //edit_doctor.php en edit_medic.php ro
// This page is for editing a doctor record.
// This page is accessed through list_doctor.php.
//header('Content-type: text/html; charset=utf-8');
//header('Content-Type: text/html; charset=widows-cp1250' );
$page_title = 'Editează Medic';
include ('includes/header.html');

echo '<h1>Detalii Medic';
if (isset($_SESSION['first_name'])) {
echo ", {$_SESSION['first_name']}";
}
if (isset($_SESSION['user_id'])) {
echo ", User ID: {$_SESSION['user_id']}";

}
echo '!</h1>';

//aici e 1 cu cel de jos, adika daca nu e logat nu are acces la baza de date
// Display links based upon the login status:
if (isset($_SESSION['user_id'])) {

// Check for a valid user ID, through GET or POST:
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // From list_doctor.php
$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form submission.
$id = $_POST['id'];
} else { // No valid ID, kill the script.
echo '<p class="error">This page has been accessed in error1.</p>';
include ('includes/footer.html'); 
exit();
}

require ('mysqli_fa_conexiunea.php');

// Check if the form has been submitted:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

$errors = array();

// Check for a first name:
if (empty($_POST['numele'])) {
    $errors[] = 'Câmpul Numele este gol !';
} else {
    $num = mysqli_real_escape_string($dbc, trim($_POST['numele']));
}

    // Check for a first name:
if (empty($_POST['initiala_tatalui'])) {
    $errors[] = 'Câmpul Inițiala Tatălui este gol !';
} else {
    $ita = mysqli_real_escape_string($dbc, trim($_POST['initiala_tatalui']));
}

// Check for a last name:
if (empty($_POST['prenumele'])) {
    $errors[] = 'Câmpul Prenumele este gol !';
} else {
    $pre = mysqli_real_escape_string($dbc, trim($_POST['prenumele']));
}

    // Check for a previous name:
//if (empty($_POST['numele_anterior'])) {
//  $errors[] = 'Câmpul Numele Anterior este gol !';
//} else {
    $nan = mysqli_real_escape_string($dbc, trim($_POST['numele_anterior']));
//}

    $sex = mysqli_real_escape_string($dbc, trim($_POST['sex']));

    // Check CNP:
if (empty($_POST['cnp'])) {
    $errors[] = 'Câmpul CNP este gol !';
} else {
    $cnp = mysqli_real_escape_string($dbc, trim($_POST['cnp']));
}

// Check for an email address:
if (empty($_POST['adresa_email'])) {
    $errors[] = 'Câmpul Adresa Email este gol !';
} else {
    $aem = mysqli_real_escape_string($dbc, trim($_POST['adresa_email']));
}

    // Check for a speciality2:
//if (empty($_POST['specialitate2'])) {
//  $errors[] = 'Ați uitat sa introduceți Specialitate 2.';
//} else {

    $speci2 = mysqli_real_escape_string($dbc, trim($_POST['specialitate2']));
            $an_abs_univ = mysqli_real_escape_string($dbc, trim($_POST['an_abs_univ']));
            $seria_dipl_univ = mysqli_real_escape_string($dbc, trim($_POST['seria_dipl_univ']));
            $nr_dipl_univ = mysqli_real_escape_string($dbc, trim($_POST['nr_dipl_univ']));
            $stare = mysqli_real_escape_string($dbc, trim($_POST['stare']));
            $cod_parafa = mysqli_real_escape_string($dbc, trim($_POST['cod_parafa']));
            $first_name = $_POST['first_name'];
            $user_id = $_POST['user_id'];
            $cm_nr = mysqli_real_escape_string($dbc, trim($_POST['cm_nr']));
            $cm_data_elib = mysqli_real_escape_string($dbc, trim($_POST['cm_data_elib']));
//}

    // Validate the university...
//if ( isset($_POST['universit']) && filter_var($_POST['universit'], FILTER_VALIDATE_INT, array('min_range' => 1))  ) {
//  $univ = $_POST['universit'];
//} else { // No artist selected.
//  $errors[] = 'Vă rugăm selectați Universitatea !';
//}

if (empty($errors)) { // If everything's OK.

    //  Test for unique email address:
    $q = "SELECT medic_id FROM medici WHERE adresa_email='$aem' AND medic_id != $id";
    $r = @mysqli_query($dbc, $q);
    if (mysqli_num_rows($r) == 0) {
            //  Test for unique CNP:
    $q = "SELECT medic_id FROM medici WHERE cnp='$cnp' AND medic_id != $id";
    $r = @mysqli_query($dbc, $q);
    if (mysqli_num_rows($r) == 0) {

        // Make the query:
        $q = "UPDATE medici SET numele='$num', initiala_tatalui='$ita', prenumele='$pre', numele_anterior='$nan', cnp='$cnp', adresa_email='$aem', stare='$stare', cod_parafa='$cod_parafa', specialitate2='$speci2', an_abs_univ='$an_abs_univ', seria_dipl_univ='$seria_dipl_univ', nr_dipl_univ='$nr_dipl_univ',  cm_nr='$cm_nr', cm_data_elib='$cm_data_elib', data_modificarii=NOW(), first_name='$first_name', user_id='$user_id', first_name_mod='{$_SESSION['first_name']}', user_id_mod='{$_SESSION['user_id']}' WHERE medic_id=$id LIMIT 1";//LIMIT 1
        $r = @mysqli_query ($dbc, $q);
        if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

            // Print a message:
            echo '<p><font color="red"><b>Datele Medicului au fost modificate.</b></font></p>'; 

        } else { // If it did not run OK.
            echo '<p class="error">Medicul nu a fost modificat ca urmare a unei erori de sistem.</p>'; // Public message.
            echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message.
        }
    } else { // Already registered.
        echo '<p class="error">CNP a fost deja înregistrat.</p>';
    }       
    } else { // Already registered.
        echo '<p class="error">Adresa de email a fost deja înregistrată.</p>';
    }

} else { // Report the errors.

    echo '<p class="error">The following error(s) occurred:<br />';
    foreach ($errors as $msg) { // Print each error.
        echo " - $msg<br />\n";
    }
    echo '</p><p>Vă rugăm încercați din nou.</p>';

} // End of if (empty($errors)) IF.

} // End of submit conditional.

// Always show the form...

// Retrieve the doctor's information:
$q = "SELECT universitate, numele, initiala_tatalui, prenumele, numele_anterior, sex, cnp, adresa_email, specialitate, specialitate2, an_abs_univ, seria_dipl_univ, nr_dipl_univ, first_name, user_id, data_adaugarii, first_name_mod, user_id_mod, stare, cod_parafa, cm_nr, cm_data_elib, data_modificarii FROM adm, medici, adm1 WHERE adm.adm_id=medici.adm_id AND adm1.adm1_id=medici.adm1_id AND medic_id=$id";       
$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the user's information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);

// Create the form:

echo '<form action="edit_medic.php" method="post">
<fieldset>
<p><font color="green"><b>Informații Personale:</b></font></p>
<p>Numele: <input type="text" name="numele" size="15" maxlength="15" value="' . $row[1] . '" />&nbsp;&nbsp;&nbsp;
Initiala tatalui: <input type="text" name="initiala_tatalui" size="15" maxlength="15" value="' . $row[2] . '" />&nbsp;&nbsp;&nbsp;
Prenumele: <input type="text" name="prenumele" size="15" maxlength="30" value="' . $row[3] . '" /></p>
<p>Numele Anterior: <input type="text" name="numele_anterior" size="15" maxlength="15" value="' . $row[4] . '" /></p>
<p>SEX: <input type="text" readonly name="sex" size="1" maxlength="1" value="' . $row[5] . '" /></p>
<p>CNP: <input type="text" name="cnp" size="15" maxlength="15" value="' . $row[6] . '" /></p>
<p>Adresa Email: <input type="text" name="adresa_email" size="50" maxlength="50" value="' . $row[7] . '"  /> </p>

<hr>
<p><font color="green"><b>Informații Medic:</b></font></p>
<p>Stare: <input type="text" readonly name="stare" size="25" maxlength="25" value="' . $row[18] . '"  /> 
&nbsp;Modifică în:<input type="radio" name="stare" value="Public" />Public <input type="radio" name="stare" value="Privat" />Privat <input type="radio" name="stare" value="Public + Privat" />Public + Privat <input type="radio" name="stare" value="Nu lucrează" />Nu lucrează <input type="radio" name="stare" value="Transferat RO" />Transferat RO <input type="radio" name="stare" value="Transferat Străinatate" />Transferat Străinătate <input type="radio" name="stare" value="Pensionar" />Pensionar <input type="radio" name="stare" value="Pensionar Public" />Pensionar Public <input type="radio" name="stare" value="Pensionar Privat" />Pensionar Privat <input type="radio" name="stare" value="Decedat" />Decedat</p>
<p>Cod Parafă: <input type="text" name="cod_parafa" size="10" maxlength="10" value="' . $row[19] . '" /></p>

<hr>
<p><font color="green"><b>Studii și Specializări:</b></font></p>

<p>Universitatea: <input type="text" readonly name="universit" size="50" maxlength="50" value="' . $row[0] . '" />&nbsp;&nbsp;&nbsp;
An Absolvire: <input type="text" name="an_abs_univ" size="4" maxlength="4" value="' . $row[10] . '"  />&nbsp;&nbsp;&nbsp;
Serie Diplomă: <input type="text" name="seria_dipl_univ" size="3" maxlength="3" value="' . $row[11] . '"  />&nbsp;&nbsp;&nbsp;
Nr. Diplomă: <input type="text" name="nr_dipl_univ" size="10" maxlength="10" value="' . $row[12] . '"  /></p>

<p>Specialitate 1: <input type="text" readonly name="specialitate" size="50" maxlength="50" value="' . $row[8] . '"  />
&nbsp;Modifică în:      
 <input type="text" name="specialitate" size="50" maxlength="50" value="' . $row[8] . '"  />

 </p>
<p>Specialitate 2: <input type="text" name="specialitate2" size="50" maxlength="50" value="' . $row[9] . '"  /></p>

<hr>
<p><font color="green"><b>Certificat de Membru</b></font></p>
<p><b>Nr. Certificat:</b> <input type="text" name="cm_nr" size="5" maxlength="5" value="' . $row[20] . '"  />
<b>Data Eliberării:</b>&nbsp; <input type="text" name="cm_data_elib" size="10" maxlength="10" value="' . $row[21] . '"  />
<hr>
<p><font color="green"><b>Evidență Adăugiri și Modificări:</b></font></p>
<p>Adăugat de: <input type="text" readonly name="first_name" size="50" maxlength="50" value="' . $row[13] . '"  />
User ID: <input type="text" readonly name="user_id" size="5" maxlength="5" value="' . $row[14] . '"  />
La data de: <input type="text" readonly name="data_adaugarii" size="15" maxlength="15" value="' . $row[15] . '"  />
<p>Modificat de: <input type="text" readonly name="first_name_mod" size="50" maxlength="50" value="' . $row[16] . '"  />
User ID: <input type="text" readonly name="user_id_mod" size="5" maxlength="5" value="' . $row[17] . '"  />
La data de: <input type="text" readonly name="data_modificarii" size="15" maxlength="15" value="' . $row[22] . '"  />
<p>Acum modifică: <input type="text" readonly name="first_name_mod" size="50" maxlength="50" value="'.$_SESSION['first_name'].'"  />
User ID: <input type="text" readonly name="user_id_mod" size="5" maxlength="5" value="'.$_SESSION['user_id'].'"  /></p>


</fieldset>
<p></p>
<p><div align="center"><input type="submit" name="submit" value="Modifică" /></p>
<input type="hidden" name="id" value="' . $id . '" />
</form>';
    echo '<form method="post" action="lista_medici.php">
<input type="submit" value="Înapoi"></div>
</form>';

} else { // Not a valid user ID.
echo '<p class="error">This page has been accessed in error2.</p>';
}

mysqli_close($dbc);

//aici e 2 cu cel de sus, adika daca nu e logat nu are acces la baza de date
} else { //  Not logged in.
    echo '<br><a href="register.php" title="Înregistrare nouă">Înregistrare nouă</a><br />
<a href="login.php" title="Autentificare">Autentificare</a><br />
<a href="forgot_password.php" title="Recuperare Parolă">Recuperare Parolă</a><br />
';
}

include ('includes/footer.html');
?>
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
  • 2
    please paste codes of what you have tried. – Sina R. Sep 28 '13 at 03:33
  • What needs to be different in `edit_doctor.php` compared to `add_doctor.php`? Why can't you use the same code as pasted here? – IMSoP Sep 28 '13 at 03:44
  • i don't know how to insert code! –  Sep 28 '13 at 03:44
  • i am here for the first time and i don't quite understand how to use form to add code. i read all helps from this website but i don't understand –  Sep 28 '13 at 03:46
  • @criss Just make sure every line that is code has at least 4 spaces at the beginning. Or select all the code and click the button that looks like `{}`, which adds them for you. – IMSoP Sep 28 '13 at 03:47
  • thank you for help me. i have succeded to post my code. i try to insert a image but i have need reputation to post image. –  Sep 28 '13 at 03:57
  • I still don't understand the question: why can you not use the same drop-down from the first page on the second page? – IMSoP Sep 28 '13 at 03:58
  • because is different situation. in edit_doctor i have echo 'form...' and doesn't work with the same script from add_doctor. i don't know where i am wrong, in format i guess. i put the code what i try. –  Sep 28 '13 at 04:02
  • Check my answer is it clear? – Ashwin Parmar Sep 28 '13 at 04:17
  • In the new code dump, is the first line of the file really ` – IMSoP Oct 01 '13 at 18:51
  • sorry, it was because i typed fast. is just the name and path of my file, just info in first lines. this file is working 100%, but i cannot add to select and change value from dropdown university and speciality for doctor. that's my big problem. –  Oct 01 '13 at 18:55
  • i put all code here http://stackoverflow.com/questions/19132666/mysql-edit-from-dropdown-list –  Oct 08 '13 at 19:15

4 Answers4

0
Hi You try this code..
I can't understand what you want? You have any queries tell me.
// Retrieve the doctor's information:
<form action="edit_doctor.php" method="post">
<fieldset>
<p><font color="green"><b>Studii și Specializări:</b></font></p>

<?php 
$q = "SELECT universitate, numele, initiala_tatalui, prenumele, numele_anterior, sex, cnp, adresa_email, specialitate, specialitate2, an_abs_univ, seria_dipl_univ, nr_dipl_univ, first_name, user_id, data_adaugarii, first_name_mod, user_id_mod, stare, cod_parafa, data_modificarii FROM adm, medici, adm1 WHERE adm.adm_id=medici.adm_id AND adm1.adm1_id=medici.adm1_id AND medic_id=$id";        
$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the doctor's information:
while($row = mysqli_fetch_array ($r, MYSQLI_NUM))
{?>

// Create the form:
<input type="hidden" name="id" value="<?php echo $id;?>" />
<p>Universitatea: <input type="text" readonly name="universit" size="50" maxlength="50" value="<?php echo $row[0]; ?>" />

<?php }}?>

</fieldset>
<p></p>
<p><div align="center"><input type="submit" name="submit" value="Modifică" /></p>

</form>
Punitha
  • 152
  • 1
  • 12
  • i used echo statement in edit doctor because i need to retrieve a doctor informations from database (i have many fields, some text, varchar...etc...). in add_doctor was simple because i have not to retrieve any information, just add new. in edit i want to list all info, and edit if it changes –  Sep 28 '13 at 04:21
  • what you got?please check it out $row while loop values are come are not.print $row values; – Punitha Oct 03 '13 at 04:11
  • all code is here http://stackoverflow.com/questions/19132666/mysql-edit-from-dropdown-list –  Oct 08 '13 at 19:14
0

It seems your problem has nothing to do with databases or drop-downs, just basic PHP syntax.

There are multiple ways of outputting HTML from PHP; simplifying a bit:

  • Any text outside the <?php ... ?> wrapper is output. So in your first file, you have ?><form ...> to output a form, and when you want more PHP, you re-open with <?php.
  • The echo statement outputs a string epxression - a variable, a function, or a quoted string. So in your second file, you have echo '<form... and the string carries on until the matching ', with ; to mark the end of the echo.

In your attempted code, you are mixing the two: you are still inside the string started with a ', but you have pasted a <?php. This won't work.

All you need to do is have more than one echo, so you can end the echo '...'; and then start it again:

echo '<form action="edit_doctor.php" method="post">
... 
<select name="universit"><option>Selectează</option>';
// Retrieve all the artists and add to the pull-down menu.
$q = "SELECT adm_id, CONCAT_WS(' ', universitate) FROM adm ORDER BY universitate ASC";      
$r = mysqli_query ($dbc, $q);
// ...
mysqli_close($dbc); // Close the database connection.
echo '
...
</fieldset>
...
</form>';
IMSoP
  • 89,526
  • 13
  • 117
  • 169
  • i insert echo ' statement inside echo but doesn't work. i get blank page. –  Sep 28 '13 at 11:37
  • The `echo` is not *inside* the echo. Each `echo` is a separate statement executed by PHP. The line doesn't need to be a complete block of HTML, just some text to output. So you can split up further to `echo '
    '; echo '
    ';` and so on if you want. Or you can use the `?>some output
    – IMSoP Sep 28 '13 at 12:51
  • Yes i understand. but in edit mode i need to show University in text field and in the right side to have dropdown menu to select other University value if it change it. i'm stack... –  Sep 29 '13 at 16:01
  • @criss I don't understand. You can `echo` as many pieces of information as you need. In your `add_doctor.php` code you already choose which option should be selected when the page loads, so you can do the same based on the database. For text fields, you need to echo the right string in the `value="..."` attribute. – IMSoP Sep 29 '13 at 16:38
  • yes, i understand but how can i do that? i must interogate database to find university for retrive info about doctor and in same form to select from dropdown list of university (based on other ID, separated in other table) to change it if i want. i have 2 tables, one for doctors, and one for university. hope to you understand. thank you for your time. if not i will put here sql table. –  Oct 01 '13 at 13:03
  • @criss Again, you can retrieve as many pieces of data as you need. Perhaps it would help to break the problem down: get each piece working separately, and then put them together, rather than thinking of it as one big task. This is really what programming is about: identifying the parts you need, and using the programming language to build them and put them together. – IMSoP Oct 01 '13 at 18:19
  • i do this from 3 weeks ago, without succes.thats i'm here. i'm new here, because i need help. i cannot see where i'm wrong. all code from you, from Punitha, shows good but i get blank page. i work hard, daily, step by step, but something i was wrong. i think to put entire code from edit_doctor here, maybe it's simple syntax bad, or something. –  Oct 01 '13 at 18:26
  • @criss Sorry to hear you're struggling to get it working. I'm trying to think of tips that will help you find the way in the future, rather than concentrating on the single problem. There are tips on working out where an error is coming from here: http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – IMSoP Oct 01 '13 at 18:47
  • ok, i put above in my post code from edit_doctor.php file. in my lang called edit_medic.php. this is single problem from start. thank's –  Oct 01 '13 at 18:47
  • i have put all code here http://stackoverflow.com/questions/19132666/mysql-edit-from-dropdown-list –  Oct 08 '13 at 19:14
0

Can you try this and use same Form Code.

if (mysqli_num_rows($r) == 1) 
{
    $action = "edit_doctor.php";
}
else
{
    $action = "add_doctor.php";
}

echo '<form action="$action" method="post">';
Ashwin Parmar
  • 3,025
  • 3
  • 26
  • 42
  • thanks for your suggest but i dont understand how to...i must to colect data from database, and select from dropdown list other value in edit_medic.php in that form. –  Sep 28 '13 at 04:30
0
<?php
// Retrieve the doctor's information:
$q = "SELECT universitate, numele, initiala_tatalui, prenumele, numele_anterior, sex, cnp, adresa_email, specialitate, specialitate2, an_abs_univ, seria_dipl_univ, nr_dipl_univ, first_name, user_id, data_adaugarii, first_name_mod, user_id_mod, stare, cod_parafa, data_modificarii FROM adm, medici, adm1 WHERE adm.adm_id=medici.adm_id AND adm1.adm1_id=medici.adm1_id AND medic_id='".$id."'";        
$r = @mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form.

// Get the doctor's information:
$row = mysqli_fetch_array ($r, MYSQLI_NUM);

// Create the form:
?>
<form action="edit_doctor.php" method="post">
<fieldset>
<p><font color="green"><b>Studii și Specializări:</b></font></p> 

<p><b>Universitatea:</b> 
<select name="universit"><option>Selectează</option>
<?php // Retrieve all the artists and add to the pull-down menu.
$q = "SELECT adm_id, CONCAT_WS(' ', universitate) FROM adm ORDER BY universitate ASC";      
$r = mysqli_query ($dbc, $q);
if (mysqli_num_rows($r) > 0) {
    while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
        ?>
   <option value="<?php echo $row[0];?>" <?php if (isset($_POST['universit']) && ($_POST['universit'] == $row[0]) ){ echo ' selected="selected"'; }?>>
   <?php echo $row[1];?>
   </option>
   <?php }
} else {
    echo '<option>Vă rugăm adăugați o Universitate prima dată.</option>';
}
mysqli_close($dbc); // Close the database connection.
?>
...
</fieldset>
<p></p>
<p><div align="center"><input type="submit" name="submit" value="Modifică" /></p>
<input type="hidden" name="id" value="<?php echo $id;?>" />
</form>
Punitha
  • 152
  • 1
  • 12
  • doesn't work. i must have value from database list and posibility to change if i want. –  Sep 28 '13 at 11:39
  • here i put all code from edit_medic.php http://stackoverflow.com/questions/19132666/mysql-edit-from-dropdown-list –  Oct 08 '13 at 19:13