Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

osanseviero

  • 4 years ago

This is a PHP code to solve syllogisms...any suggestion to make better this code (i know it is in Spanish some parts, sorry)

  • This Question is Closed
  1. osanseviero
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    <html> <body> <center> <table> Silogismos </table> <form method="post" action="chobbisilogismo.php"> <table border=3 align=center> <tr> <td> <select name="1x"> <option>Todo</option> <option>Algun</option> </select> </td> <td> <input name="1p" type="text" value="Ingresa termino aqui" /> </td> <td> <select name="1y"> <option>es</option> <option>no es</option> </select> </td> <td> <input name="1q" type="text" value="Ingresa termino aqui" /> </td> <tr> <td> <select name="2x"> <option>Todo</option> <option>Algun</option> </select> </td> <td> <input name="2p" type="text" value="Ingresa termino aqui"/> </td> <td> <select name="2y"> <option>es</option> <option>no es</option> </select> </td> <td> <center> <input name="2q" type="text" value="Ingresa termino aqui" /> </td> <tr> <td colspan="4"><center><input type="Submit" value="Resolver Silogismo"></center></td> </tr> </form> <?PHP $X1=$_POST['1x']; $Y1=$_POST['1y']; $P1=$_POST['1p']; $Q1=$_POST['1q']; $X2=$_POST['2x']; $Y2=$_POST['2y']; $P2=$_POST['2p']; $Q2=$_POST['2q']; $F=0; $A=A; $E=E; $I=I; $O=O; $M=0; $N=0; $S=0; if($P1=="Ingresa termino aqui") {$J=0;} else {$J=1;}; if($Q1=="Ingresa termino aqui") {$V=0;} else {$V=1;}; if($Q2=="Ingresa termino aqui") {$T=0;} else {$T=1;}; if($P2=="Ingresa termino aqui") {$B=0;} else {$B=1;}; $K=$J+$V+$T+$B; if($P1==$Q2){$P=$P2;$Q=$Q1;$F=1;} else{ if($Q1==$Q2){$P=$P2;$Q=$P1;$F=2;} else{ if($P1==$P2){$P=$Q2;$Q=$Q1;$F=3;} else{ if($Q1==$P2){$P=$Q2;$Q=$P1;$F=4;} else{ echo " <tr> <td colspan= 4> <center> Corrige tu ortografía en el término medio </center> </td> </tr>"; $S=0;};;};;};}; if($X1=="Todo" && $Y1=="es") {$M=$A;} else{ if($X1=="Todo" && $Y1=="no es") {$M=$E;} else{ if($X1=="Algun" && $Y1=="es") {$M=$I;} else{ if($X1=="Algun" && $Y1=="no es") {$M=$O;} else{echo "Qué pedo?!?!";};};};}; if($X2=="Todo" && $Y2=="es") {$N=$A;} else{ if($X2=="Todo" && $Y2=="no es") {$N=$E;} else{ if($X2=="Algun" && $Y2=="es") {$N=$I;} else{ if($X2=="Algun" && $Y2=="no es") {$N=$O;} else{echo "Qué pedo?!?!";};};};}; if($F==1 && $M=="A" && $N=="A") {$X="Todo"; $Y="es";} else{ if($F==1 && $M=="E" && $N=="A") {$X="Todo"; $Y="no es";} else{ if($F==1 && $M=="A" && $N=="I") {$X="Algun"; $Y="es";} else{ if($F==1 && $M=="E" && $N=="I") {$X="Algun"; $Y="no es";} else{ if($F==2 && $M=="E" && $N=="A") {$X="Todo"; $Y="es";} else{ if($F==2 && $M=="A" && $N=="E") {$X="Todo"; $Y="no es";} else{ if($F==2 && $M=="E" && $N=="I") {$X="Algun"; $Y="no es";} else{ if($F==2 && $M=="A" && $N=="O") {$X="Algun"; $Y="no es";} else{ if($F==3 && $M=="A" && $N=="A") {$X="Algun"; $Y="es";} else{ if($F==3 && $M=="I" && $N=="A") {$X="Algun"; $Y="es";} else{ if($F==3 && $M=="A" && $N=="I") {$X="Algun"; $Y="es";} else{ if($F==3 && $M=="E" && $N=="A") {$X="Algun"; $Y="no es";} else{ if($F==3 && $M=="O" && $N=="A") {$X="Algun"; $Y="no es";} else{ if($F==3 && $M=="E" && $N=="I") {$X="Algun"; $Y="no es";} else{ if($F==4 && $M=="A" && $N=="A") {$X="Algun"; $Y="es";} else{ if($F==4 && $M=="A" && $N=="E") {$X="Todo"; $Y="no es";} else{ if($F==4 && $M=="I" && $N=="A") {$X="Algun"; $Y="es";} else{ if($F==4 && $M=="E" && $N=="A") {$X="Algun"; $Y="no es";} else{ if($F==4 && $M=="E" && $N=="I") {$X="Algun"; $Y="no es";} else{ $S=1;};};};};};;};};};};};};};};};};};};};}; if ($S==0) { echo " <tr> <td><center>"; echo $X1; echo" </center></td> <td><center>"; echo $P1; echo" </center></td> <td><center>"; echo $Y1; echo" </center></td> <td><center>"; echo $Q1; echo" </center></td> </tr> <tr> <td><center>"; echo $X2; echo" </center></td> <td><center>"; echo $P2; echo" </center></td> <td><center>"; echo $Y2; echo" </center></td> <td><center>"; echo $Q2; echo" </center></td> </tr> <tr> <td><center>"; echo $X; echo" </center></td> <td><center>"; echo $P; echo" </center></td> <td><center>"; echo $Y; echo" </center></td> <td><center>"; echo $Q; echo" </center></td> </tr> </table> </center>";} else{ echo " <tr> <td><center>"; echo $X1; echo" </center></td> <td><center>"; echo $P1; echo" </center></td> <td><center>"; echo $Y1; echo" </center></td> <td><center>"; echo $Q1; echo" </center></td> </tr> <tr> <td><center>"; echo $X2; echo" </center></td> <td><center>"; echo $P2; echo" </center></td> <td><center>"; echo $Y2; echo" </center></td> <td><center>"; echo $Q2; echo" </center></td> </tr> <tr> <td colspan=4>"; echo "<center>No se puede concluir nada</center>"; echo" </td> </tr> </table> </center>";}; ?> </body> </html>

  2. Tomas.A
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    use pastebin.com to show your code

  3. agdgdgdgwngo
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://ideone.com/jsaB4 I don't know HTML, nor do I know PHP. However, you do have very deeply-nested if-else blocks. Perhaps they are working too hard? Are they trying to do both input validation and logic?

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy