Ir para conteúdo
Fórum Script Brasil
  • 0

Select só retorna último valor


Guest papelbm

Pergunta

Pessoal, Boa noite,

Estou precisando de ajuda, tenho uma página em php onde ela puxa dados de outra via GET, porém necessito que em um multiselect, retorne todos dos modelos cadastrados nesta operação, e ela só está retornando o ultimo, ou somente o que selecionei se coloco o mesmo na consulta, segue o codigo abaixo:


<?php
header("charset=ISO-8859-1",true);
$banco= mysql_connect("localhost","root","");
mysql_select_db("bdprocesso10", $banco);

$operacao = $_GET['operacao'];
$time = $_GET['time'];
$posto = $_GET['posto'];
$modelo =$_GET['modelo'];

?>

<!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>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/miniatura imagem.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title>
</head>


<body>
<?php
$query = "SELECT O.num operacao, O.descr, O.pr, O.numero, O.classe, T.descr time, OP.posto, M.nome modelo FROM operacao O INNER JOIN time T ON O.time=T.cod_time INNER JOIN modelo_op OP ON OP.operacao=O.num INNER JOIN modelo M ON op.modelo=m.id WHERE numero = $operacao and time = $time";
$executa = mysql_query($query, $banco);

while ($op= mysql_fetch_array($executa))

{
    $descr=$op["descr"];
    $pr=$op["pr"];
    $numero=$op["numero"];
    $time=$op["time"];
    $posto=$op["posto"];
    $classe=$op["classe"];
    $modelo=$op["modelo"];
    }
                     
?>
<form name="forma" method="POST" action="" enctype="multipart/form-data">
<table width="200" border="0" class="body2">
<tr>
<td colspan="4">Descri&ccedil;&atilde;o:
<input name="descr" type="text" id="descr" style="width:1000px" value="<?php echo $descr; ?> "></td>
</tr>
<tr>
<td width="153">N&uacute;mero da Opera&ccedil;&atilde;o:
<input type="text" name="numero" id="numero" style="width:170px" value="<?php echo $numero;?>"></td>
<td width="316">PR:
<input type="text" name="pr" id="pr" style="width:400px" value="<?php echo $pr;?>"></td>
<td width="157">Time:
<select name="time" id="time" style="width:150px" title="">
<option value=""<?php echo $time;?>""><?php echo $time;?></option>
</select></td>
<td width="130">Posto:
<select name="posto" id="posto" style="width:150px">
<option value="<?php echo $posto;?>"><?php echo $posto;?></option>
</select></td>
</tr>
<tr>
<td>Classe: 
<select name="classe" id="classe" style="width:140px">
<option value="<?php echo $classe;?>"><?php echo $classe;?></option> 
</select></td>
<td><script src="select.js" language="javascript"></script>
<script>
$(document).ready(function(){
jQuery.fn.selectmove = function(){
var $div = $(this);
$div.find('select').delegate('option','dblclick',function(){
$select = $(this).closest('select').index('select');
$option = $(this);
var destino = $select==0?1:0
$option.remove();
$div.find('select').eq(destino).append($option);
});
$div.find('#remove_todos').click(function(){
$div.find('select:eq(1) option').each(function(){
$(this).remove().appendTo($div.find('select').eq(0));
}); 
});
$div.find('#move_todos').click(function(){
$div.find('select:eq(0) option').each(function(){
$(this).remove().appendTo($div.find('select').eq(1));
}); 
});
$div.find('#move_sel').click(function(){
$div.find('select').eq(0).find('option:selected').remove().appendTo($div.find('select').eq(1));
});
$div.find('#remove_sel').click(function(){
$div.find('select').eq(1).find('option:selected').remove().appendTo($div.find('select').eq(0));
});
}
$('#select_move').selectmove();
});
</script>
<p>&nbsp;</p>
Modelo(s):<table border="0">
    <tr>
        <td>
            <div id="select_move">
<div id="div_select_1">
<select name="sel_modelo" multiple>
<option>Selecione uma Classe</option>
</select>
</div>
<div id="controles">
<p>&nbsp;</p>
<p><input type="button" value="<" id="remove_sel"></p>
<p><input type="button" value=">" id="move_sel"></p>
<p>&nbsp;</p> 
</div>
<div id="div_select_2">
<select name="modelo[]" size="10" multiple>
<option value="<?php echo $modelo;?>"><?php echo $modelo;?></option>

</select>
</div> 
</div>
        </td>
    </tr>
</table></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4"><p>
<label>Selecionar Imagem da Folha:<br>
<input type='file' name="folha" id="folha" onchange="readURL(this);" />
<img id="blah" src="#" alt="your image" />

</label>
</p></td>
</tr>
<tr>
<td colspan="4"><input type="submit" name="enviar" id="enviar" value="Cadastrar Folha";></td>
</tr>
</table>
</form>
</body>
</html>

Por que após isso irei editar os dados,

Desde já agradeço.

Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,9k
×
×
  • Criar Novo...