php - Show data saved previously in Mysql database with implode -


i need know how can show data saved in database , make actions treatment info. need show info first capture always...can me these?

here captures:

this 1 when treatment info prepare save database: treatment prepare save db

and other when data in database: treatments after saved db

here code:

include_once("configs.php"); if (!empty($_post)) {     try{         $diente_id = is_array($_post['diente_id']) ? implode(', ', $_post['diente_id']) : $_post['diente_id'];         $cara = is_array($_post['cara']) ? implode(', ', $_post['cara']) : $_post['cara'];         $tratamiento = is_array($_post['tratamiento']) ? implode(', ', $_post['tratamiento']) : $_post['tratamiento'];         $stmt = $conn->prepare('insert odontograma (diente_id, cara, tratamiento, id_paciente)          values (:diente_id, :cara, :tratamiento, :id_paciente)');            $stmt->bindparam(':diente_id', $diente_id);         $stmt->bindparam(':cara', $cara);         $stmt->bindparam(':tratamiento', $tratamiento);         $stmt->bindparam(':id_paciente', $_post['id_paciente']);         $stmt->execute();         echo 'registro ingresado correctamente.';                                    }     catch (pdoexception $e)      {         error_log($e->getmessage());         die($e->getmessage());     } } 

the form in page:

<form name="dentista" id="dentista" method="post">         <table class="table table-striped table-condensed">             <thead>                 <tr>                     <th><?php $translate->__('date'); ?></th>                     <th><?php $translate->__('id'); ?></th>                     <th><?php $translate->__('aplicar a'); ?></th>                     <th><?php $translate->__('treatment'); ?></th>                     <th><?php $translate->__('actions'); ?></th>                 </tr>             </thead>                <tbody>                 <?php                      $sql = $conn->prepare("select id_odont, diente_id, cara, tratamiento , date_format(f_odonto, '%d %m %y') f_odonto odontograma id_paciente=? order id_odont desc");                     $sql->execute(array($_get['id_paciente']));                     while($row = $sql->fetch(pdo::fetch_assoc)) {                 ?>                 <tr>                     <td><?php echo $row['f_odonto']; ?></td>                     <td><?php echo $row['diente_id']; ?></td>                     <td><?php echo $row['cara']; ?></td>                     <td><?php echo $row['tratamiento']; ?></td>                     <td></td>                 </tr><?php } ?>             </tbody>             <tbody data-bind="foreach: tratamientosaplicados">                 <tr>                     <td></td>                     <td><span data-bind="text: diente.id" id="diente.id"></span><input type="hidden" name="diente_id[]" data-bind="value: diente.id" /></td>                     <td><span data-bind="text: cara" id="cara"></span><input type="hidden" name="cara[]" data-bind="value: cara" /></td>                     <td><span data-bind="text: tratamiento.nombre" id="tratamiento"></span><input type="hidden" name="tratamiento[]" data-bind="value: tratamiento.nombre" /></td>                     <td>                         <a href="#" data-bind="click: $parent.quitartratamiento" class="btn btn-danger">                             <i class="icon-trash icon-white"></i>                         </a>                     </td>                 </tr>             </tbody>         </table>     <input type="hidden" name="id_paciente" value="<?php echo $id_paciente; ?>" />     <input type="submit" class="btn btn-primary" value="<?php $translate->__('save odontogram'); ?>" /> </form> <div id="loading" style="display:none;"><img src="img/ajax-loaders/loading4.gif" /></div> 

the js:

$("#dentista").submit(function(){ $.ajax({ type:"post", url:"include/odonto.php?ts=" + new date().gettime(), datatype:"text", data:$(this).serialize(), beforesend:function(){ $("#loading").show(); }, success:function(response){ $("#loading").hide(); }  }) return false; }); 

and last, how can in same ajax call make insert, update or delete treatment or all?


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -