Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 17/04/2011, 22h29   #1
 
Inscription : janvier 2011
Messages : 43
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 43
Points : -9
Points : -9
Par défaut probleme de isset

boujour,

voila j'ai un souci avec le code suivant :

Code :
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
<?php
$db = new PDO('mysql:host=localhost;dbname=LCDS', 'root', '');
if (isset($_GET['idv']))
{
        if ((!isset($_POST['moin'])) || (!isset($_POST['plus'])))
	{
		$idv = $_GET['idv'];
		$query=$db->prepare('SELECT * FROM vin WHERE vin_id = :idv');
		$query->bindValue(':idv',$idv,PDO::PARAM_INT);
		$query->execute();
		$data = $query->fetch();
		echo '<form action="mi.php?idv='.$data['vin_id'].'" method="post">';
		echo '<table>
		<tr>
		<th><strong>Nom</strong></th>
		<th><strong>Achat</strong></th>
		<th><strong>Vente</strong></th>
		<th><strong>Quantité</strong></th>
		<th><strong>Prix Unité</strong></th>       
		<th><strong>Prix Total H.T</strong></th>
		<th><strong>Fournisseur</strong></th>			
		<th><strong>Modifier</strong></th>			
		</tr>';
 
		echo '<tr>
		<td>'.$data['vin_nom'].'&nbsp;('.$data['vin_l'].')</td>
		<td><input type="text" name="plus" /></td>
		<td><input type="text" name="moin" /></td>
		<td>'.$data['vin_qte'].'</td>
		<td>'.$data['vin_pu'].'</td>
		<td>'.(($data['vin_qte'])*($data['vin_pu'])).'</td>
		<td>'.$data['vin_f'].'</td>
		<td><input type="submit" value="Modifier" /></td></tr>';
 
		$query->CloseCursor();
		echo '</table></form>';
	}
	elseif (isset($_POST['moin']))
	{
		$idv = $_GET['idv'];
		$query=$db->prepare('SELECT * FROM vin WHERE vin_id = :idv');
		$query->bindValue(':idv',$idv,PDO::PARAM_INT);
		$query->execute();
		$data = $query->fetch();
 
		$moin1 = $_POST['moin'];
		$moin2 = $data['vin_qte'];
		echo $moin1;
		echo '<br>';
		echo $moin2;
		echo '<br><br>';
		$moin =  '('.$moin1.') - ('.$moin2.')';
		echo $moin;
		echo '<br><br>';
		$test = '3'-'3';
		echo $test;
	}
	elseif (isset($_POST['plus']))
	{
		$idv = $_GET['idv'];
		$query=$db->prepare('SELECT * FROM vin WHERE vin_id = :idv');
		$query->bindValue(':idv',$idv,PDO::PARAM_INT);
		$query->execute();
		$data = $query->fetch();
 
		$plus1 = $_POST['plus'];
		$plus2 = $data['vin_qte'];
		$plus = ($plus1)+($plus2);
 
		echo 'lol';
		echo 'mdr';
	}		
}
else
{
	$vin = 'vin';
	$query=$db->query('SELECT * FROM `vin` ORDER BY `vin`.`vin_nom` ASC');
 
	echo '<table>
	<tr>
	<th><strong>Nom</strong></th>             
	<th><strong>Fournisseur</strong></th>       
	<th><strong>Prix Unité</strong></th>       
	<th><strong>Quantité</strong></th>       
	<th><strong>Prix Total H.T</strong></th>       
	<th><strong>Modifier</strong></th>       
	</tr>';
	while ($data = $query->fetch())
	{
		echo '<tr><td>'.$data['vin_nom'].'&nbsp;('.$data['vin_l'].')</td><td>'.$data['vin_f'].'</td><td>'.$data['vin_pu'].'</td><td>'.$data['vin_qte'].'</td><td>'.(($data['vin_qte'])*($data['vin_pu'])).'</td><td class="modif"><span class="menu4"><a href="mi.php?idv='.$data['vin_id'].'">Modifier</a></span></td></tr>';
	}
	$query->CloseCursor();
	echo '</table>';
}
?>
quand je rentre un chiffre dans le <input type="text" name="plus" /> ce la me fait :

Citation:
3

() - (3)

0
alors que sa devrai m'afficher :

Citation:
lolmdr
et quand je rentre un chiffre dans le <input type="text" name="moin" /> sa marche comme je le veux.

pouvez-vous m'aider ?
sourcilpower est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/04/2011, 22h43   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
Que le champ de formulaire soit rempli ou non, isset() est vrai.
Il faut que tu vérifies en plus ce qu'il vaut.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/04/2011, 22h48   #3
 
Inscription : janvier 2011
Messages : 43
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 43
Points : -9
Points : -9
merci de ta reponse
sourcilpower est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/04/2011, 22h53   #4
Membre régulier
 
Inscription : novembre 2008
Messages : 108
Détails du profil
Informations forums :
Inscription : novembre 2008
Messages : 108
Points : 88
Points : 88
bonsoir,
avec la fonction empty

burndev est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/04/2011, 22h54   #5
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
empty() n'est pas une bonne solution puisqu'il eliminera les 0.
Il y a juste a tester si on a une chaine vide ou non.
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 17/04/2011, 22h58   #6
Membre régulier
 
Inscription : novembre 2008
Messages : 108
Détails du profil
Informations forums :
Inscription : novembre 2008
Messages : 108
Points : 88
Points : 88
exact autant pour moi

comme dit sabotage le teste de la chaine vide est la meilleur option
Code :
if($_POST['champ'] == "") ou if($_POST['champ'] != "")
burndev est déconnecté   Envoyer un message privé Réponse avec citation 01
Vieux 17/04/2011, 23h07   #7
 
Inscription : janvier 2011
Messages : 43
Détails du profil
Informations forums :
Inscription : janvier 2011
Messages : 43
Points : -9
Points : -9
merci pour votre reponse probleme resolue
sourcilpower est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h53.


 
 
 
 
Partenaires

Hébergement Web