1. Al select ponle un orden: select * from materiales order by campo; para sacar los datos siempre en el mismo orden.
2. A este codigo le falta mostrar el option elegido antes.
Código PHP:
<?php
echo "<select name=\"materiales\">\n";
$result1 = pg_query($connection, "select * from materiales order by descrip_mat");
if (pg_num_rows($result1) != 0){
While ($registro=pg_fetch_assoc($result1)) {
if ($registro['descrip_mat']==$_POST['materiales'])
echo "<option value= \"".$registro['cod_material']."\" selected>".$registro['descrip_mat']."</option>\n";
else
echo "<option value= \"".$registro['cod_material']."\">".$registro['descrip_mat']."</option>\n";
$d=$registro['descrip_mat'];
$_SESSION["des"]=$d;
}
}
echo "</select>\n\n";
?>