Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/01/2014, 09:21
charly_lpg
 
Fecha de Ingreso: octubre-2013
Mensajes: 56
Antigüedad: 10 años, 6 meses
Puntos: 1
Select PHP MYSQL

Hola
Tengo un select desde una consulta a una base de datos MYSQL y lo tengo que enviar por post a otro PHP para haga un insert en otra tabla

Tengo 2 problemas

Problema 1
hace 2 veces el mismo insert

Problema 2
el select lo hago bien pero no puedo hacer que cargue la opcion elegida.

le paso los 2 codigos.

CODIGO 1
<form action="actnot.php" method="post">
<table>
<?php
echo"<tr>
<td>CIA</td>
<td>";
$sql = "SELECT DISTINCT cia,nombre FROM ciasgeneral order by nombre asc";
$res = mysqli_query($conn, $sql);
echo"<select>";
while($fila = mysqli_fetch_assoc($res)){;
echo"<option name=".$fila['cia']." id=".$fila['cia']." selected='selected'>".$fila['nombre']."";
}
echo"</select>
</td>
</tr>
<tr>
<td>Fecha de Vencimiento</td>
<td><input type='date' name='vto' id='vto'></td>
<tr>
<td>Noticia</td>
<td><textarea rows='4' cols='50' name='noticia' id='noticia'></textarea></td>
</tr>
<tr>
<td><button type='submit'>CARGAR</button></td>
<td><button type='reset'>LIMPIAR</button></td>
</tr>
</table>
</form>";
?>
----------------------------------------------------------------------------------------------------
CODIGO 2

<?php
$hoy = date("Y-m-d");
$sql="INSERT INTO noticias (cia,fecha,vencimiento,noticia) VALUES ('".$_POST['cia']."','".$hoy."','".$_POST['vto']."','".$_POST['noticia']."')";
mysqli_query($conn,$sql);

if (!mysqli_query($conn,$sql))
{
die('Error: ' . mysqli_error($conn));
}
echo "Se agrego la noticia";

mysqli_close($conn);
?>