Bonjour,
j'ai crée un input de recherche (comme la bar google). J'ai suivi ce tuto : .
Donc sa fonctionne très bien maintenant je voudrais faire une insertion au dans ma bdd au niveau ma fonction stricte.
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 $(document).ready(function(){ $('#search').keyup(function(){ var search = $(this).val(); search = $.trim(search); if(search !== "") { $('#loader').show(); $.post('large',{search:search},function(data){ $('#resultat ul').html(data).show(); $('#loader').hide(); //clique sur le lien $('a').click(function(){ var lien =$(this).text(); $('#loader').show(); $('#search').attr('value', lien); $.post('stricte',{lien:lien},function(data){ $('#feedback').html(data); $('#loader').hide(); $('#resultat ul').hide(); }); }); }); } }); });
user_model :
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 function stricte() { if((isset($_POST['lien']))&& (!empty($_POST['lien']))) { $lien =mysql_real_escape_string($_POST['lien']); if($this->user_model->un($lien) != null) { foreach ($this->user_model->un($lien) as $r) { $nom = $r->NOM; $id = $r->ID ; $data = array('nom'=>$nom, 'id'=>$id); $this->user_model->inserttampon($data); redirect('admin/tableau'); } }else{ echo "<p> <strong>".$_POST['lien']."</strong></p>"; } } } function tableau() { echo "<table>"; echo"<tr>"; echo"<th>Nom</th>"; echo"</tr>"; echo"<tr>"; echo"<td>"; echo "test"; echo"</td>"; echo"</tr>"; echo"</table>"; }
Si je met en commentaire le inserttampon dans admin la liste marche normalement.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 function inserttampon($data) { $this->db->insert('tampon_commande',$data); }
Je ne vois pas ou ce trouve le probleme.
Partager