PHP - envio registro lista multiple

 
Vista:

envio registro lista multiple

Publicado por la bruja (1 intervención) el 13/09/2008 23:29:31
buenas tardes, mi problema es el suguiente, tengo una lista multiple y deseo enviar varios registros a un campo de una tabla, o sea que los registros esten separados por coma, entonces les mostrare mi codigo para guardar un solo registro, espero me ayuden a modificarlo.... gracias de antemano..


<?php
include("conexion.php");
?>
<?php
$id = $_GET['id'];
$link=Obtenerconexion();
if(isset($_GET['ok']))
{
$query="INSERT INTO subprocesos(subproceso) VALUES ('".$_GET['pro']."')";
$resultado=mysql_query($query,$link);
$mensaje="Datos Almacenados Correctamente";
}

?>
<?php
echo $mensaje;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PRUEBA FORO</title>
// UNA VEZ TRAIDO LOS DATOS DE LA BD A LA LISTA REALIZO ESTE CODIGO PARA QUE AL SELECCIONARLO SE PUEDA VER EL VALOR POR MEDIO DE CUADROS DE TEXTOS...

<script type="text/javascript">
function get_name_from_list(){
if(document.getElementById('names_list')){
if(document.getElementById('id')){
if(document.getElementById('pro')){

var id = document.getElementById('names_list').options[document.getElementById('names_list').selectedIndex].value;
var pro = document.getElementById('names_list').options[document.getElementById('names_list').selectedIndex].text;

document.getElementById('id').value=id;
document.getElementById('pro').value=pro;



}else{alert('Element pro not found!!!');}
}else{alert('Element id not found!!!');}
}else{alert('Element names_list not found!!!');}
}
</script>
</head>

<body>
<?php
$link=Obtenerconexion();
$resump=mysql_query("SELECT * FROM procesos ", $link);

?>
<form id="form1" name="form1" method="get" action="">

<select onchange="get_name_from_list()" name="names_list" multiple="multiple" id="names_list" >
<option value="">Seleccionar</option>
<?php
while ($row1=mysql_fetch_array($resump))
{

print "<option value='".$row1["id"]."' >
".$row1["proceso"]."</option>";
}
?>

</select>

<input type="hidden" size="5" name="id" id="id"/>
Proceso:
<input type="text" size="35" name="pro" id="pro" />

<input type="submit" name="ok" id="ok" value="ok" />


////////////////solo lo coloco para ver con mayor facilidad la carga de los datos.
<?php
$link=Obtenerconexion();
$resump=mysql_query("SELECT * FROM subprocesos ", $link);

?>
<form id="form1" name="form1" method="get" action="">

<select onchange="get_name_from_list()" name="names_list" id="names_list" >
<option value="">Seleccionar</option>
<?php
while ($row1=mysql_fetch_array($resump))
{

print "<option value='".$row1["id"]."' >
".$row1["subproceso"]."</option>";
}
?>

</select>


</form>
</body>
</html>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder