External form and $.ajax
Permalink
Im trying to populate a chained select with ajax but im getting a error as you can see in the attachment. im working with external forms and i have the following code:
Teste - external form
and the db.php file wich the function in external form uses.
can anyone help me on this? i really need to make it work for a project.
Teste - external form
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); Loader::Helper('form'); ?> <!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=iso-8859-1" /> <script type="text/javascript" src="<?php echo $this->getThemePath()?>/jquery.min.js"></script> <!--http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js... --> <script type="text/javascript"> $(document).ready(function() { $("#parent_category").change(function() { var pc_id = $(this).val();
Viewing 15 lines of 59 lines. View entire code block.
and the db.php file wich the function in external form uses.
<?php if(isset($_POST['pc_id']) && $_POST['pc_id'] != '') { $pc_id = $_POST['pc_id']; $pc_id = mysql_real_escape_string($pc_id); $query = "SELECT condisciplinas.Cod_disciplinas, condisciplinas.Nome_disciplinas, concursos.Cod_curso FROM condisciplinas INNER JOIN (concursos INNER JOIN concursodisciplina ON concursos.Cod_curso = concursodisciplina.Curso) ON condisciplinas.Cod_disciplinas = concursodisciplina.Disciplina WHERE (((concursos.Cod_curso)='".$pc_id."'))"; $res = mysql_query($query); if(mysql_num_rows($res)) { while($row = mysql_fetch_array($res)) { echo "<option value='".$row['Cod_disciplinas']."'>".ucfirst($row['Nome_disciplinas'])."</option>"; } }
Viewing 15 lines of 17 lines. View entire code block.
can anyone help me on this? i really need to make it work for a project.
It seems your sql query is not returning valid sql resource. First check your sql query and connection. Accoding to your code you have not set your sql connection.
Thanks