IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Utilisation d' un tableau


Sujet :

PHP & Base de données

  1. #21
    Candidat au Club
    Femme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2017
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Madagascar

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Janvier 2017
    Messages : 14
    Points : 3
    Points
    3
    Par défaut
    Bonjour,
    J'ai bien vérifier mais il n'y a aucun $hS1.
    La récupération est le même non, même si c'est avec les frameworks?

  2. #22
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Si tu as un message d'erreur qui parle d'une variable hS1, c'est qu'elle est mentionnée dans ton code, PHP ne l'invente pas.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #23
    Candidat au Club
    Femme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2017
    Messages
    14
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 33
    Localisation : Madagascar

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Janvier 2017
    Messages : 14
    Points : 3
    Points
    3
    Par défaut
    Bonjour,
    voila mon code:

    1)en modèle
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
     
    <?php
     
    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
     
    class Pointage_model extends CI_Model
    {
     
        public $table = 'pointage';
     
        public $id = 'idP';
        public $order = 'DESC';
     
        function __construct()
        {
            parent::__construct();
        }
     
        // get all
        function get_all()
        {
            $this->db->order_by($this->id, $this->order);
            return $this->db->get($this->table)->result();
        }
     
        // get data by id
        function get_by_id($id)
        {
            $this->db->where($this->id, $id);
            return $this->db->get($this->table)->row();
        }
     
        // get total rows
        function total_rows($q = NULL) {
            $this->db->like('idP', $q);
    	$this->db->or_like('matricule', $q);
    	$this->db->or_like('nom', $q);
    	$this->db->or_like('groupe', $q);
    	$this->db->or_like('date1', $q);
    	$this->db->or_like('date2', $q);
    	$this->db->or_like('hE1', $q);
    	$this->db->or_like('hS1', $q);
    	$this->db->or_like('hN1', $q);
    	$this->db->or_like('hSup1', $q);
    $this->db->from($this->table);
            return $this->db->count_all_results();
        }
     
        // get data with limit and search
        function get_limit_data($limit, $start = 0, $q = NULL) {
            $this->db->order_by($this->id, $this->order);
            $this->db->like('idP', $q);
    	$this->db->or_like('matricule', $q);
    	$this->db->or_like('nom', $q);
    	$this->db->or_like('groupe', $q);
    	$this->db->or_like('date1', $q);
    	$this->db->or_like('date2', $q);
    	$this->db->or_like('hE1', $q);
    	$this->db->or_like('hS1', $q);
    	$this->db->or_like('hN1', $q);
    	$this->db->or_like('hSup1', $q);
     function insert($data)
        {
            $this->db->insert($this->table, $data);
              }

    2) en vue

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    <!doctype html>
    <html>
        <head>
            <title>harviacode.com - codeigniter crud generator</title>
            <link rel="stylesheet" href="<?php echo base_url('assets/bootstrap/css/bootstrap.min.css') ?>"/>
            <link rel="stylesheet" href="<?php echo base_url('assets/datatables/dataTables.bootstrap.css') ?>"/>
            <style>
                body{
                    padding: 15px;
                }
            </style>
        </head>
        <body>
            <div class="row" style="margin-bottom: 10px">
                <div class="col-md-4">
                    <h2 style="margin-top:0px">Pointage List</h2>
                </div>
                <div class="col-md-4 text-center">
                    <div style="margin-top: 4px"  id="message">
                        <?php echo $this->session->userdata('message') <> '' ? $this->session->userdata('message') : ''; ?>
                    </div>
                </div>
                <div class="col-md-4 text-right">
                    <?php echo anchor(site_url('pointage/create'), 'Create', 'class="btn btn-primary"'); ?>
    		<?php echo anchor(site_url('pointage/excel'), 'Excel', 'class="btn btn-primary"'); ?>
    		<?php echo anchor(site_url('pointage/word'), 'Word', 'class="btn btn-primary"'); ?>
    	    </div>
            </div>
     
            <table class="table table-bordered table-striped" id="mytable">
                <thead>
                    <tr>
                        <th width="80px">No</th>
    		    <th>Matricule</th>
    		    <th>Nom</th>
    		    <th>Groupe</th>
    		    <th>Date1</th>
    		    <th>Date2</th>
    		    <th>HE1</th>
    		    <th>HS1</th>
    		    <th>HN1</th>
    		    <th>HSup1</th>
               </thead>
    	    <tbody>
                <?php
     
                $start = 0;
     
                foreach ($pointage_data as $pointage)
                {
                	?>
                    <tr>
    		    <td><?php echo ++$start ?></td>
    		    <td><?php echo $pointage->matricule ?></td>
    		    <td><?php echo $pointage->nom ?></td>
    		    <td><?php echo $pointage->groupe ?></td>
    		    <td><?php echo $pointage->date1 ?></td>
    		    <td><?php echo $pointage->date2 ?></td>
    		    <td><?php echo $pointage->hE1?></td>
    		    <td><?php echo $pointage->hS1?></td>
                        <td><?php echo $pointage->hN1; echo date_create_from_format('H\hi',  $_POST['hS1'])->diff(date_create_from_format('H\hi',  $_POST['hE1']))->format('%hh%I');?></td>
                        <td><?php echo $pointage->hSup1 ?></td>
     
    		    </td>
    	        </tr>
                    <?php
                }
                ?>
                </tbody>
            </table>
            <script src="<?php echo base_url('assets/js/jquery-1.11.2.min.js') ?>"></script>
            <script src="<?php echo base_url('assets/datatables/jquery.dataTables.js') ?>"></script>
            <script src="<?php echo base_url('assets/datatables/dataTables.bootstrap.js') ?>"></script>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("#mytable").dataTable();
                });
            </script>
        </body>
    </html>

    et 3) en controller

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
     
    <?php
     
    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
     
    class Pointage extends CI_Controller
    {
        function __construct()
        {
            parent::__construct();
            $this->load->model('Pointage_model');
            $this->load->library('form_validation');
        }
     
        public function index()
        {
            $pointage = $this->Pointage_model->get_all();
     
            $data = array(
                'pointage_data' => $pointage
            );
     
            $this->load->view('pointage/pointage_list', $data);
        }
     
        public function read($id) 
        {
            $row = $this->Pointage_model->get_by_id($id);
            if ($row) {
                $data = array(
    		'idP' => $row->idP,
    		'matricule' => $row->matricule,
    		'nom' => $row->nom,
    		'groupe' => $row->groupe,
    		'date1' => $row->date1,
    		'date2' => $row->date2,
    		'hE1' => $row->hE1,
    		'hS1' => $row->hS1,
    		'hN1' => $row->hN1,
    		'hSup1' => $row->hSup1,
                     );
                $this->load->view('pointage/pointage_read', $data);
            } else {
                $this->session->set_flashdata('message', 'Record Not Found');
                redirect(site_url('pointage'));
            }
        }
     
     
     
        public function create() 
        {
            $data = array(
                'button' => 'Create',
                'action' => site_url('pointage/create_action'),
     
    	    'idP' => set_value('idP'),
    	    'matricule' => set_value('matricule'),
    	    'nom' => set_value('nom'),
    	    'groupe' => set_value('groupe'),
    	    'date1' => set_value('date1'),
    	    'date2' => set_value('date2'),
    	    'hE1' => set_value('hE1'),
    	    'hS1' => set_value('hS1'),
     
    	    'hSup1' => set_value('hSup1'),
                    'tHSup' => set_value('tHSup'),
    	);
            $this->load->view('pointage/pointage_form', $data);
        }
     
        public function create_action() 
        {
            $this->_rules();
     
     
            if ($this->form_validation->run() == FALSE) {
                $this->create();
     
            } else {
     
                $data = array(
     
    		'matricule' => $this->input->post('matricule',TRUE),
    		'nom' => $this->input->post('nom',TRUE),
    		'groupe' => $this->input->post('groupe',TRUE),
    		'date1' => $this->input->post('date1',TRUE),
    		'date2' => $this->input->post('date2',TRUE),
    		'hE1' => $this->input->post('hE1',TRUE),
    		'hS1' => $this->input->post('hS1',TRUE),
     
    		'hSup1' => $this->input->post('hSup1',TRUE),
                     );
     
                $this->Pointage_model->insert($data);  
                $this->session->set_flashdata('message', 'Create Record Success');
                redirect(site_url('pointage'));
            }
        }
    Et c'est sur la vue en ligne 92 qu'il y a erreur
    Nom : ERREUR.jpg
Affichages : 73
Taille : 203,7 Ko
    Dois-je déplacer mon code ou le modifier?


    Merci!

Discussions similaires

  1. [VBA-E] Utilisation d'un tableau en réseau (multi-utilisateurs)
    Par Mourne dans le forum Macros et VBA Excel
    Réponses: 23
    Dernier message: 15/02/2007, 00h37
  2. [Tableaux] Utilisation d'un tableau
    Par Skippy1 dans le forum Langage
    Réponses: 7
    Dernier message: 04/01/2007, 09h07
  3. probléme dans l'utilisation d'un tableau
    Par hamoudasafira dans le forum C++
    Réponses: 10
    Dernier message: 13/12/2006, 08h50
  4. [Tableaux] utilisation d'un tableau à deux dimensions
    Par calitom dans le forum Langage
    Réponses: 1
    Dernier message: 28/11/2006, 18h01
  5. [C#]Quel objet utiliser pour un tableau..
    Par Jinroh77 dans le forum Windows Forms
    Réponses: 3
    Dernier message: 16/10/2006, 20h22

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo