bonjour
je suis débutant dans le php mysql et je travail sur joomla ,j'ais fait un exemple de table en trois colonnes juste pour connaitre le principe de l'interrogation
pour cela je vous demande de bien vouloir me corrigé le scripte si dessus
non de la base : basjoomla
non user : root
pwd : ""
non de la table : tcs
les colonnes : (tc,position ,information)
je veut faire un insert et un select de resultat
merci
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
101
102
103
104
105
106
107
108
109
110
 
<body>
 
Ajout:   <br/><br/>
<form id="form1" name="form1" method="post" >
  <label for="tc">tc</label>   <input type="text" name="tc" id="tc" /> <br/><br/>
 
 
 
  <label for="position">position</label>   <input type="text" name="position" id="position" />  <br/><br/>
 
 
 
  <label for="information">information</label>   <input type="text" name="information" id="information" /> <br/><br/>
 
 
 
  <input type="submit" name="valider" id="valider" value="Valider" />
 
</form> <br/><br/>
 
Affichage des resultats: <br/><br/>
<form id="form2" name="form2" method="post" >
<label for="tc">tc</label>   <input type="text" name="tc" id="tc" />  <input type="submit" name="afficher" id="afficher" value="Afficher" />  
</form>
 
<br/><br/>
 
 
 
 
<?php 
// Affichage 
 
if(isset($valider) )
{
	mysql_connect("localhost", "root", "admin");
	mysql_select_db("basjoomla");
	//$sql="select * from tcs";
 
	$tc          = $_POST['tc'];
	$position    = $_POST['position'];
	$information = $_POST['information'];
 
 
	// le formulaire 
 
	 $sql = "INSERT INTO tcs(tc, position,information) VALUES( '$tc','$position','$information')"; 
 
	 mysql_query($sql);
 }
 
 
 
 
 
 
 
 
 
 
 
 
	if(isset($afficher))
{
 
	mysql_connect("localhost", "root", "admin");
	mysql_select_db("basjoomla");
 
	$tc          = $_POST['tc'];
 
	 $sql="select * from tcs WHERE tc = '$tc' ";
 
	$R=mysql_query($sql);
 
	  while ($ligne=mysql_fetch_object($R))
			 {			  
				  $tc          = $ligne->tc;
				  $position    = $ligne->position;
				  $information = $ligne->information ;
 
 
?>
 
<table width="408" border="1">
  <tr>
    <th width="59" scope="col">tc</th>
    <th width="194" scope="col">position</th>
    <th width="133" scope="col">information</th>
  </tr>
  <tr>
    <td><?=$tc?></td>
    <td><?=$position?></td>
    <td><?=$information?></td>
  </tr>
</table>
 
<br/><br/>
<label for="tc">tc</label>   <input type="text" name="tc" id="tc"  value="<?=$tc?>"/> <br/><br/>
 
<label for="position">position</label>   <input type="text" name="position" id="position" value="<?=$position?>"/>  <br/><br/>
 
<label for="information">information</label>   <input type="text" name="information" id="information"  value="<?=$information?>"/> <br/><br/>
 
 
 
<?
 }
 }
 ?>