php mysql combobox更新不行

Thanks in advance and sorry, but my English is not very good. I was having problems with the update of a combobox. I can make that combobox come loaded with the data from the table and to appear selected the record stored in the table, but at the time of editing the registry, the table is saved with a 0 (zero). I can't find the error.

Here's the code for the combobox for the INSERT

Laboratorio: 
<select name="lab" size="0">
    <?php
        $sql = 'SELECT * FROM laboratorios order by lab_Nombre asc';
        $res = mysql_query($sql);
        while ($array = mysql_fetch_array($res)) { ?>
            <option value="<?php echo $array['lab_Id']?>"><?php echo $array['lab_Nombre']?> </option>
    <?php } ?>
</select><br/><br/>

Here's the code for the combobox for the UPDATE

Laboratorio: 
<select name="lab" size="0">
    <?php
        $sqlLab = 'SELECT * FROM laboratorios order by lab_Nombre asc';
        $resLab = mysql_query($sqlLab);
        while ($arrayLab = mysql_fetch_array($resLab)) 
        { ?>
            <option value=<?php 
                            if ($array['ac_Lab']==$arrayLab['lab_Id'])
                            {
                                echo $arrayLab['lab_Id']?> selected="selected"><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } 
                            else
                            { ?>
                                <option value=<?php echo $arrayLab['lab_Id']?> ><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } ?>
    <?php } ?>
</select><br/><br/>

The table to modify is:

CREATE TABLE IF NOT EXISTS `laboratorios` (
  `lab_Id` smallint(3) NOT NULL AUTO_INCREMENT,
  `lab_Nombre` varchar(50) NOT NULL,
  `lab_Contacto` varchar(50) DEFAULT NULL,
  `lab_Mail` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`lab_Id`)
) ENGINE=MyISAM AUTO_INCREMENT=42

coming from the following table:

`ac_Id` smallint(6) NOT NULL AUTO_INCREMENT,
`ac_Desc` varchar(50) NOT NULL,
`ac_Cat` varchar(50) NOT NULL,
`ac_Lab` smallint(6) NOT NULL,
`ac_Apli` varchar(200) NOT NULL,
`ac_Prov` smallint(6) NOT NULL,
`ac_Alm` smallint(6) NOT NULL,
`ac_Vol` smallint(6) NOT NULL,
`ac_Dil` varchar(50) DEFAULT NULL,
`ac_Img` varchar(50) DEFAULT NULL,
`ac_Obs` varchar(200) DEFAULT NULL,
PRIMARY KEY (`ac_Id`)

OK, thanks so much!!

You will save yourself a lot of headaches by switching over to PDO or mysqli* functions now, rather than using mysql* functions, which are deprecated.

PDO Manual

Mysqli Manual

Why you shouldn't use Mysql_* functions

Is it possible that the error is in not having double or single quotes around the <?php echo $arrayLab['lab_Id']?> & I would suggest to post your SQL, but having error reporting turned on will definitely help, as well as using PDO or mysqli as they are currently not under active development. (could not post as comment cause I need 50 rep..)

Remove the size="0" because that may modify your final data in your form

Look at the HTML you're generating:

start an <option>:

<option value=[..snip...]

do a test

if ($array['ac_Lab']==$arrayLab['lab_Id']) {
   [..snip..]
} else {
   <option value=<?php echo $arrayLab['lab_Id']?> ><?php echo $arrayLab['lab_Nombre']?> </option>
   ^^^^^^^^^^^^^---- start ANOTHER option

For every element which ISN'T "selected" (which is usually all of them except for one, you're building this:

<option value=<option value=$someid>

which is outright illegal html.

In the code:

Laboratorio: 
<select name="lab">
    <?php
        $sqlLab = 'SELECT * FROM laboratorios order by lab_Nombre asc';
        $resLab = mysql_query($sqlLab);
        while ($arrayLab = mysql_fetch_array($resLab)) 
        { ?>
            <option value=<?php 
                            if ($array['ac_Lab']==$arrayLab['lab_Id'])
                            {
                                echo $arrayLab['lab_Id']?> selected="selected"><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } 
                            else
                            { ?>
                                <option value=<?php echo $arrayLab['lab_Id']?> ><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } ?>
    <?php } ?>
</select><br/><br/>

after the "else" i put a <option for more...

The code now is:

Laboratorio: 
<select name="lab">
    <?php
        $sqlLab = 'SELECT * FROM laboratorios order by lab_Nombre asc';
        $resLab = mysql_query($sqlLab);
        while ($arrayLab = mysql_fetch_array($resLab)) 
        { ?>
            <option value=<?php 
                            if ($array['ac_Lab']==$arrayLab['lab_Id'])
                            {
                                echo $arrayLab['lab_Id']?> selected="selected"><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } 
                            else
                            { 
                                echo $arrayLab['lab_Id']?> ><?php echo $arrayLab['lab_Nombre']?> </option>
                      <?php } ?>
    <?php } ?>
</select><br/><br/>

Thanks so much!!