Error entering a data to the glyphicon

1

When entering a data that I have in the database in a table I get all the arrays well but when entering it in a glyphicon so that it does not look "ugly" it is put in the same detail of all the arrays. Personalize some suggestion pls

           <td><?php echo $Nticket; ?></td>
                    <td><?php echo $incidencia; ?></td>
                    <td><?php echo $tema; ?></td>
                    <td><a data-toggle="modal" href="#myModal"><li 
               class='glyphicon glyphicon-info-sign'></li></a>
          <div class="modal fade" id="myModal" role="dialog">
       <div class="modal-dialog">
   <div class="modal-content">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;
       </button>
      <h4 class="modal-title">Detalle de la incidencia</h4>
    </div>
    <div class="modal-body">
      <p><?php echo $detalle;?></p>
    </div>
    <div class="modal-footer">
      <button type="button" class="btn btn-default" data-
     dismiss="modal">Cerrar</button>
    </div>
  </div>

</div>

  

The first one is like I do not want to make it look messy

the second is how I want it to be

and the third is the detail that appears in all the data of the detail that always appears the same be the data that is

the ajax code that loads the table and the search for items

include('is_logged.php');//Archivo verifica que el usario que intenta acceder a la URL esta logueado
/* Connect To Database*/
require_once ("../config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
require_once ("../config/conexion.php");//Contiene funcion que conecta a la base de datos
$action = (isset($_REQUEST['action'])&& $_REQUEST['action'] !=NULL)?$_REQUEST['action']:'';
if (isset($_GET['Nticket'])){
    $incidencia=intval($_GET['Nticket']);
    $query=mysqli_query($con, "select * from ticket where Nticket='".$Nticket."'");
    $rw_user=mysqli_fetch_array($query);
    $count=$rw_ticket['Nticket'];
    if ($Nticket!=1){
        if ($delete1=mysqli_query($con,"DELETE FROM ticket WHERE Nticket='".$Nticket."'")){
        ?>
        <div class="alert alert-success alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Aviso!</strong> Datos eliminados exitosamente.
        </div>
        <?php 
    }else {
        ?>
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Error!</strong> Lo siento algo ha salido mal intenta nuevamente.
        </div>
        <?php

    }

    } else {
        ?>
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Error!</strong> No se pudo eliminar ésta  categoría. Existen productos vinculados a ésta categoría. 
        </div>
        <?php
    }



}
if($action == 'ajax'){
    // escaping, additionally removing everything that could be (html/javascript-) code
     $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
     $aColumns = array('Nticket');//Columnas de busqueda
     $sTable = "ticket";
     $sWhere = "";
    if ( $_GET['q'] != "" )
    {
        $sWhere = "WHERE (";
        for ( $i=0 ; $i<count($aColumns) ; $i++ )
        {
            $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
        }
        $sWhere = substr_replace( $sWhere, "", -3 );
        $sWhere .= ')';
    }
    $sWhere.=" order by Nticket";
    include 'pagination.php'; //include pagination file
    //pagination variables
    $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
    $per_page = 10; //how much records you want to show
    $adjacents  = 4; //gap between pages after number of adjacents
    $offset = ($page - 1) * $per_page;
    //Count the total number of row in your table*/
    $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
    $row= mysqli_fetch_array($count_query);
    $numrows = $row['numrows'];
    $total_pages = ceil($numrows/$per_page);
    $reload = './clientes.php';
    //main query to fetch the data
    $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
    $query = mysqli_query($con, $sql);
    //loop through fetched data
    if ($numrows>0){
        ?>
    <div class="table-responsive">
          <table class="table">
            <tr  class="danger">
                <th>ticket</th>
                <th>Incidencia</th>
                <th>Tema</th>
                <th>Detalle</th>
            </tr>
                <?php
        $nums=1;
            while ($row=mysqli_fetch_array($query)){
                    $Nticket=$row['Nticket'];
                    $incidencia=$row['incidencia'];
                    $tema=$row['tema'];
                    $detalle=$row['detalle'];



                    ?>


                <input type="hidden" value="<?php echo $row['Nticket'];?>" id="Nticket<?php echo $Nticket;?>">
                <input type="hidden" value="<?php echo $row['incidencia'];?>" id="incidencia<?php echo $incidencia;?>">
                <input type="hidden" value="<?php echo $row['tema'];?>" id="tema<?php echo $tema;?>">
                <input type="hidden" value="<?php echo $row['detalle'];?>" id="detalle<?php echo $detalle;?>">

                <tr>
                    <td><?php echo $Nticket; ?></td>
                    <td><?php echo $incidencia; ?></td>
                    <td><?php echo $tema; ?></td>
                    <td><a data-toggle="modal" href="#myModal"><li 
                   class='glyphicon glyphicon-info-sign'></li></a>
                <div class="modal fade" id="myModal" role="dialog">
           <div class="modal-dialog">
           <div class="modal-content">
          <div class="modal-header">
       <button type="button" class="close" data-dismiss="modal">&times;
              </button>
           <h4 class="modal-title">Detalle de la incidencia</h4>
       </div>
        <div class="modal-body">
        <p><?php echo $detalle;?></p>
     </div>
      <div class="modal-footer">
       <button type="button" class="btn btn-default" data-
           dismiss="modal">Cerrar</button>
      </div>
      </div>

          </div>
     </div>

                                                                                                                                                              

    
asked by Kevin Salazar 28.09.2017 в 23:46
source

1 answer

1

Try doing the following

include('is_logged.php');//Archivo verifica que el usario que intenta acceder a la URL esta logueado
/* Connect To Database*/
require_once ("../config/db.php");//Contiene las variables de configuracion para conectar a la base de datos
require_once ("../config/conexion.php");//Contiene funcion que conecta a la base de datos
$action = (isset($_REQUEST['action'])&& $_REQUEST['action'] !=NULL)?$_REQUEST['action']:'';
if (isset($_GET['Nticket'])){
    $incidencia=intval($_GET['Nticket']);
    $query=mysqli_query($con, "select * from ticket where Nticket='".$Nticket."'");
    $rw_user=mysqli_fetch_array($query);
    $count=$rw_ticket['Nticket'];
    if ($Nticket!=1){
        if ($delete1=mysqli_query($con,"DELETE FROM ticket WHERE Nticket='".$Nticket."'")){
        ?>
        <div class="alert alert-success alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Aviso!</strong> Datos eliminados exitosamente.
        </div>
        <?php 
    }else {
        ?>
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Error!</strong> Lo siento algo ha salido mal intenta nuevamente.
        </div>
        <?php

    }

    } else {
        ?>
        <div class="alert alert-danger alert-dismissible" role="alert">
          <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <strong>Error!</strong> No se pudo eliminar ésta  categoría. Existen productos vinculados a ésta categoría. 
        </div>
        <?php
    }



}
if($action == 'ajax'){
    // escaping, additionally removing everything that could be (html/javascript-) code
     $q = mysqli_real_escape_string($con,(strip_tags($_REQUEST['q'], ENT_QUOTES)));
     $aColumns = array('Nticket');//Columnas de busqueda
     $sTable = "ticket";
     $sWhere = "";
    if ( $_GET['q'] != "" )
    {
        $sWhere = "WHERE (";
        for ( $i=0 ; $i<count($aColumns) ; $i++ )
        {
            $sWhere .= $aColumns[$i]." LIKE '%".$q."%' OR ";
        }
        $sWhere = substr_replace( $sWhere, "", -3 );
        $sWhere .= ')';
    }
    $sWhere.=" order by Nticket";
    include 'pagination.php'; //include pagination file
    //pagination variables
    $page = (isset($_REQUEST['page']) && !empty($_REQUEST['page']))?$_REQUEST['page']:1;
    $per_page = 10; //how much records you want to show
    $adjacents  = 4; //gap between pages after number of adjacents
    $offset = ($page - 1) * $per_page;
    //Count the total number of row in your table*/
    $count_query   = mysqli_query($con, "SELECT count(*) AS numrows FROM $sTable  $sWhere");
    $row= mysqli_fetch_array($count_query);
    $numrows = $row['numrows'];
    $total_pages = ceil($numrows/$per_page);
    $reload = './clientes.php';
    //main query to fetch the data
    $sql="SELECT * FROM  $sTable $sWhere LIMIT $offset,$per_page";
    $query = mysqli_query($con, $sql);
    //loop through fetched data
    if ($numrows>0){
        ?>
    <div class="table-responsive">
          <table class="table">
            <tr  class="danger">
                <th>ticket</th>
                <th>Incidencia</th>
                <th>Tema</th>
                <th>Detalle</th>
            </tr>
                <?php
        $nums=0;
            while ($row=mysqli_fetch_array($query)){
                    $Nticket=$row['Nticket'];
                    $incidencia=$row['incidencia'];
                    $tema=$row['tema'];
                    $detalle=$row['detalle'];

                    $nums++;



                    ?>


                <input type="hidden" value="<?php echo $row['Nticket'];?>" id="Nticket<?php echo $Nticket;?>">
                <input type="hidden" value="<?php echo $row['incidencia'];?>" id="incidencia<?php echo $incidencia;?>">
                <input type="hidden" value="<?php echo $row['tema'];?>" id="tema<?php echo $tema;?>">
                <input type="hidden" value="<?php echo $row['detalle'];?>" id="detalle<?php echo $detalle;?>">

                <tr>
                    <td><?php echo $Nticket; ?></td>
                    <td><?php echo $incidencia; ?></td>
                    <td><?php echo $tema; ?></td>
                    <td><a data-toggle="modal" href="#myModal_<?php echo $nums; ?>"><li 
                   class='glyphicon glyphicon-info-sign'></li></a>
                <div class="modal fade" id="myModal_<?php echo $nums; ?>" role="dialog">
           <div class="modal-dialog">
           <div class="modal-content">
          <div class="modal-header">
       <button type="button" class="close" data-dismiss="modal">&times;
              </button>
           <h4 class="modal-title">Detalle de la incidencia</h4>
       </div>
        <div class="modal-body">
        <p><?php echo $detalle;?></p>
     </div>
      <div class="modal-footer">
       <button type="button" class="btn btn-default" data-
           dismiss="modal">Cerrar</button>
      </div>
      </div>

          </div>
     </div>

In summary:

  • To your variable $nums assign an increment $num++ within your cycle while

  • The value of the attribute href of the label <a> that opens the modal change it to "#myModal_<?php echo $nums; ?>"

  • The value of the attribute id of your modal change it to "myModal_<?php echo $nums; ?>"

  • I hope it works for you, regards!

    EXPLANATION

    When you were painting the <a> tags and modal in your code, they always had the same id , that is, the <a> tags always pointed to the same id of the modal, that's why with the variable $nums the% dynamic_co co is made by adding a unique number to the end.

        
    answered by 29.09.2017 / 00:09
    source