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!!