Este es mi codigo
Código:
Con el codigo asi, me genera la grafica, pero no me condiciona los resultados a la segunda consulta(que son los datos que provienen de un formulario) .$mes1=$_POST["mes1"]; $mes2=$_POST["mes2"]; $year1=$_POST["year1"]; $year2=$_POST["year2"]; $sexo=$_POST["A2"]; $edad1=$_POST["A3a"]; $edad2=$_POST["A3b"]; $comunidad=$_POST["A8"]; $ocupacion=$_POST["A7"]; $estadocivil=$_POST["A4"]; $ayuda=$_POST["A14"]; $result = mysql_query("SELECT * FROM cierre", $bd) or die('ERROR: '.mysql_error()); $result2 = mysql_query("SELECT * FROM identificacion WHERE (A2='$sexo' or '$sexo' = '') AND ((A3 >= '$edad1' and A3 <='$edad2') or '$edad1' = '') AND (A8='$comunidad' or '$comunidad' = '') AND (A7='$ocupacion' or '$ocupacion' = '') AND (A4='$estadocivil' or '$estadocivil' = '') AND (A14='$ayuda' or '$ayuda' = '')", $bd) or die('ERROR: '.mysql_error()); while($row2= mysql_fetch_assoc($result2)) { while($row= mysql_fetch_assoc($result)) { if($row['D1']=="1") { $B++; } if($row['D1']=="2") { $C++; } if($row['D1']=="3") { $D++; } if($row['D1']=="4") { $E++; } if($row['D1']=="5") { $F++; } if($row['D1']=="6") { $G++; } if($row['D1']==0) { $A++; } } } $total2=$A+$B+$C+$D+$E+$F+$G; $a=array('Mucho mejor','Mejor','Ni mejor ni peor','Peor','Mucho peor','No se sugirio','No se especifico'); $ydata = array($B,$C,$D,$E,$F,$G,$A); $maximo=max(array_values($ydata)); $total3=$maximo; $graph = new Graph(1024,600, "auto"); $graph->SetScale("textlin",0,$total3); $graph->img->SetMargin(70, 50, 60, 130); $graph->SetBackgroundGradient($aFrom='white',$aTo='dodgerblue3',$aGradType=2,$aStyle=BGRAD_MARGIN); $graph->title->Set("A la pregunta ¿te sientes mejor? Respondió\n"); $graph->title->SetFont(FF_ARIAL,FS_NORMAL,20, "center", "center"); $graph->subtitle->Set("$titulo\n"); $graph->subtitle->SetFont(FF_ARIAL,FS_NORMAL,12, "top", "center"); $graph->xaxis->title->Set("Total $total2 registros\n$fechaA $fechaB hrs."); $graph->title->SetMargin(10); $graph->xaxis->SetTitlemargin(80); $graph->yaxis->title->Set("Total" ); $graph->yaxis->SetTitlemargin(50); // Setup font for axis $graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,10); $graph->yaxis->SetFont(FF_ARIAL,FS_NORMAL,10); // Show 0 label on Y-axis (default is not to show) $graph->yscale->ticks->SupressZeroLabel(false); $graph->xaxis->SetTickLabels($a); $graph->xaxis->SetLabelAngle(50); $barplot =new BarPlot($ydata); $barplot->SetColor("orange"); $barplot->SetFillColor('dodgerblue4'); $barplot->value->Show(); $graph->Add($barplot); $graph->Stroke();
Aca dejo la captura de como tengo mi grafica ahora:
![](http://img854.imageshack.us/img854/4140/64t0.png)
En total en mi base de datos tengo 4 registros, pero solo 3 de sexo femenino, el problema esta en que me muestra todos y no solo los de sexo femenino, que es lo que se pide desde el formulario.
Espero que me haya dado a entender y que me puedan ayudar.
Muchas gracias