Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Galera boa tarde!!!
não sei como fazer...
tenho em 1 pagina 2 campos select:
Cursos
Turmas
o q preciso é: quando selecionar o curso 1 do select Cursos, quero que no campo Turmas mostre apenas as turmas do curso 1, como faço isso??? postei aqui porque acho q consulta SQL poderei fazer, se nao for me desculpe e me falam onde é, e se possivel como fazer!!! Segue copia da pagina que estou fazendo.
<?php require_once('../../Connections/siscfc.php'); ?><?phpif (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$colname_clientes = "-1";if (isset($_POST['id_cliente'])) { $colname_clientes = $_POST['id_cliente'];}mysql_select_db($database_siscfc, $siscfc);$query_clientes = sprintf("SELECT id_cliente, nome, cpf, rg FROM tb_clientes WHERE id_cliente = %s", GetSQLValueString($colname_clientes, "int"));$clientes = mysql_query($query_clientes, $siscfc) or die(mysql_error());$row_clientes = mysql_fetch_assoc($clientes);$totalRows_clientes = mysql_num_rows($clientes);mysql_select_db($database_siscfc, $siscfc);$query_turmas = "SELECT * FROM tb_categorias";$turmas = mysql_query($query_turmas, $siscfc) or die(mysql_error());$row_turmas = mysql_fetch_assoc($turmas);$totalRows_turmas = mysql_num_rows($turmas);mysql_select_db($database_siscfc, $siscfc);$query_cursos = "SELECT id_curso, curso, apelido FROM tb_cursos ORDER BY apelido ASC";$cursos = mysql_query($query_cursos, $siscfc) or die(mysql_error());$row_cursos = mysql_fetch_assoc($cursos);$totalRows_cursos = mysql_num_rows($cursos);?><!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>Untitled Document</title><script type="text/javascript" src="../../js/ajax.js"></script><script type="text/javascript" src="../../js/funcoes.js"></script></head><body><form id="form1" name="form1" method="post" action=""> <table border="1"> <tr> <td>Nome:</td> <td><?php echo $row_clientes['nome']; ?></td> </tr> <tr> <td>CPF:</td> <td><?php echo $row_clientes['cpf']; ?></td> </tr> <tr> <td>RG:</td> <td><?php echo $row_clientes['rg']; ?></td> </tr> <tr> <td>Curso:</td> <td><label> <select name="cursos" id="cursos" > <?phpdo { ?> <option value="<?php echo $row_cursos['id_curso']?>"><?php echo $row_cursos['apelido']?></option> <?php} while ($row_cursos = mysql_fetch_assoc($cursos)); $rows = mysql_num_rows($cursos); if($rows > 0) { mysql_data_seek($cursos, 0); $row_cursos = mysql_fetch_assoc($cursos); }?> </select> </label></td> </tr> <tr> <td>Turma:</td> <td><label> <select name="turma" id="turma"> <option value="">Selecione o Curso</option> </select> </label></td> </tr> <tr> <td> </td> <td> </td> </tr> </table></form></body></html><?phpmysql_free_result($clientes);mysql_free_result($turmas);mysql_free_result($cursos);?>Carregando comentários...