Error with button and table in PHP

0

No table open in php, image where error:

Can you help me find the prooblema? When I try to open the table, I'll open the code, it does not make it the table I need, which was already working, I just added the $ result query to validate it and it does not come out anymore, they can help me with what it will be the error. Thanks, my friends, programmers.

<?php
    require '../../session.php';
    include("../../conexion.php");

    $con = new conec();
    $cnx2 = $con->conectar();
    $acreedor=$_POST['acreedor'];
    $importe2=$_POST['importe2'];
    $tipo = $_POST['tipo'];

 $result = pg_query($query = "SELECT SUM(Cast(importe as numeric(15,2))) as Total
                FROM cxpgastos
                    Where acreedor = '1040200'");
                if (!$result) {
                  echo "Ocurrió un error.\n";
                  exit;
                }

                while ($row = pg_fetch_row($result)) {

                    if ($row[0]+$importe2 >= 15000.00)


                    echo "Supera El Limite De Gasto Anual";

                      else
                          echo "Seleccion Gasto No Deducible";


                }


     if( $tipo == "1" )
        $query = "select id_tipogasto, btrim(descripcion) as nombre, deducible from emb_tiposdegasto   where deducible = 'S' order by id_tipogasto;";
    else
        $query = "select id_tipogasto, btrim(descripcion) as nombre, deducible from emb_tiposdegasto   where deducible = 'N'  order by id_tipogasto;";

    $Cat = pg_query($query);





    ?>

<table id="tbTipos" width="100%" border="0" cellpadding="0" cellspacing="0">
    <thead>
            <tr>
                <th width="5%" scope="col">ID</th>
                <th width="10%" scope="col">Descripcion</th>
                <th width="5%" scope="col">Deducible</th>

                <th width="1%" scope="col" align='center'>Acciones</th>


            </tr>
            <tr></tr>
    </thead>
    <tbody>
         <?php          $id=0;
                        while ($bancos = pg_fetch_object($Cat))
                        {

                            if ($numfila == 0){ $class = "alt"; $numfila = 1; } else { $class = ""; $numfila = 0; }
                                echo "<tr class'".$class."'>";
                                echo "<td align='center'>".$bancos->id_tipogasto."</td>";
                                echo "<td>".$bancos->nombre."</td>";
                                echo "<td align='center'>".$bancos->deducible."</td>";
                                //echo "<td align='center'>"."<a href=javascript:datosTipos('".$id."') rel='tipsy' title='Seleccionar'>
                                //<input type='radio' name='radio'/></a></td>";
                                echo "<td align='center'>"."<a href=javascript:datosTipos('".$id."') rel='tipsy' title='Seleccionar'>
                                              <img src='../../img/seleccionar.png' id='sel' style='vertical-align: text-top; height: 18px;'/></a> </td>";

                                echo "</tr>";
                                $id=$id+1;
                        }
                        pg_close();

          ?>
    </tbody>
    <tfoot>     </tfoot>
</table>

What will be the problem in my code since I can not find the error, that when clicking instead of opening the table I get the code of the tabala, here I leave all my code I hope you help me and thank you very much.

    
asked by 08.09.2017 в 02:07
source

2 answers

0

[This response is temporary, when the user places more information it will be edited]

I have commented everything that is connections. If you really deploy it on a php server and the code is this, you should not have errors that you mention.

This is my result and the edited code. [no clear connections and required: P] [bottom of the whole]

I have also tried to apply only part that you say has caused you the error, but there does not seem to be anything visible.

$row[0]=13000;
$importe2=1000;
$importe3=15000.00;
if ($row[0]+$importe2 >= $importe3){
    echo "Supera El Limite De Gasto Anual";
}else{
    echo "Seleccion Gasto No Deducible";
}
echo $importe3;
echo ($row[0]+$importe2);

Try placing this code on your server to see if something jumps. Then go inserting the connections and the required. Maybe the failure is not here but the data you receive from the bbdd.

<?php
    /*require '../../session.php';
    include("../../conexion.php");

    $con = new conec();
    $cnx2 = $con->conectar();
    $acreedor=$_POST['acreedor'];
    $importe2=$_POST['importe2'];
    $tipo = $_POST['tipo'];

    $result = pg_query($query = "SELECT SUM(Cast(importe as numeric(15,2))) as Total FROM cxpgastos Where acreedor = '1040200'");
    if (!$result) {
      echo "Ocurrió un error.\n";
      exit;
    }

    while ($row = pg_fetch_row($result)) {
        if ($row[0]+$importe2 >= 15000.00){
            echo "Supera El Limite De Gasto Anual";
        }else{
            echo "Seleccion Gasto No Deducible";
        }
    }

    if( $tipo == "1" ){
        $query = "select id_tipogasto, btrim(descripcion) as nombre, deducible from emb_tiposdegasto   where deducible = 'S' order by id_tipogasto;";
    }else{
        $query = "select id_tipogasto, btrim(descripcion) as nombre, deducible from emb_tiposdegasto   where deducible = 'N'  order by id_tipogasto;";
    }

    $Cat = pg_query($query);
    */
?>

<html>
    <head>
    </head>
    <body>
        <table id="tbTipos" width="100%" border="0" cellpadding="0" cellspacing="0">
            <thead>
                <tr>
                    <th width="5%" scope="col">ID</th>
                    <th width="10%" scope="col">Descripcion</th>
                    <th width="5%" scope="col">Deducible</th>
                    <th width="1%" scope="col" align='center'>Acciones</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th width="5%" scope="col">ID</th>
                    <th width="10%" scope="col">Descripcion</th>
                    <th width="5%" scope="col">Deducible</th>
                    <th width="1%" scope="col" align='center'>Acciones</th>
                </tr>
            </tfoot>
            <tbody>
                <?php          
                    $id=0;

                    $bancos->id_tipogasto = "it1";
                    $bancos->nombre = "Gasto altisimo";
                    $bancos->deducible = 0;

                    //while ($bancos = pg_fetch_object($Cat))
                    //{

                        if ($numfila == 0){ 
                            $class = "alt"; 
                            $numfila = 1; 
                        } else { 
                            $class = ""; 
                            $numfila = 0; 
                        }

                        echo "<tr class'".$class."'>";
                        echo "<td align='center'>".$bancos->id_tipogasto."</td>";
                        echo "<td>".$bancos->nombre."</td>";
                        echo "<td align='center'>".$bancos->deducible."%</td>";
                        echo "<td align='center'><a href=javascript:datosTipos('".$id."') rel='tipsy' title='Seleccionar'><img src='../../img/seleccionar.png' id='sel' style='vertical-align: text-top;height: 18px;'/></a> </td>";
                        echo "</tr>";
                        $id=$id+1;
                    //}
                    //pg_close();
                ?>
            </tbody>
        </table>
    </body>
</html>
    
answered by 08.09.2017 в 08:32
0

I'm not sure, but I think you need to include the connection in the pg_query

function
$result = pg_query($conn, "SELECT...

Example of the official PHP website link

<?php

$conn = pg_pconnect("dbname=publisher");
if (!$conn) {
  echo "Ocurrió un error.\n";
  exit;
}

$result = pg_query($conn, "SELECT author, email FROM authors");
if (!$result) {
  echo "Ocurrió un error.\n";
  exit;
}

while ($row = pg_fetch_row($result)) {
  echo "Author: $row[0]  E-mail: $row[1]";
  echo "<br />\n";
}

?>
    
answered by 10.09.2017 в 18:54