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

Problemas com SQL


web_charles

Pergunta

Eu tenho uma tabela em html que tá realizando o select de duas outras tabelas uma professor e a outra frases, criei uma outra tabela no musql para gravar os dados do formulario html tipo radio. O que preciso é gravar na tabela voto o voto desse radio, no professor e frase sequente. Segue o codigo:

<form action="cadastrar.php" method="post">
<table width="100%" border="1">
<tr>
<td width="5%" class="frases" >PROFESSOR(A)</td>

<?php
//consulta sql
$query = mysql_query("SELECT * FROM frases ORDER BY id") or die(mysql_error());

//faz um looping e cria um array com os campos da consulta
while($array = mysql_fetch_array($query))
{
//mostra na tela o nome e a data de nascimento

echo '<td width="23%" class="frases">'.$array['texto'].' </td> ';
}
?>
</tr>
<?php

//consulta sql
$query = mysql_query("SELECT * FROM professor ORDER BY id") or die(mysql_error());

//faz um looping e cria um array com os campos da consulta
while($array = mysql_fetch_array($query))
{
?>

<tr>
<?php
echo'<td class="frases"><strong>'.$array['nome'].'</strong>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
1<input name="criterio" type="radio" value="1" />
2<input name="criterio" type="radio" value="2" />
3<input name="criterio" type="radio" value="3" />
4<input name="criterio" type="radio" value="4" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>

</td>';
}
?>

</table>

Editado por web_charles
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0
Boa tarde,
Estou querendo calcular a comissao dos vendedores, isso vai variar de acordo
o total das vendas, o exemplo que estou enviando, é se por o caso o total
das vendas desse cara for maior que 100, a consulta irá multiplicar por 1.1, se
não for ele vai multiplicar por 0.9. Tenho a tabela Vendas, dentro dela eu tenho
os campos do codigo do vendedor e o total de vendas por nota. So que não
consigo executar esse codigo. Alguém poderia me ajudar?
SELECT VENDAS.VENDEDOR,
CASE SUM(VENDAS.TOTAL) AS TOTAL
WHEN > 100 THEN sum(vendas.total) * 1.1
ELSE sum(vendas.total )* 0.9
END AS COMISSAO
FROM VENDAS
WHERE VENDAS.VENDEDOR IS NOT NULL
Editado por TIAGO10
Link para o comentário
Compartilhar em outros sites

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,3k
    • Posts
      652,3k
×
×
  • Criar Novo...