Voila je m'explique.
J'ai une table de donné que voici
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
111
112
113
114
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
 
CREATE SCHEMA IF NOT EXISTS `test` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
USE `test` ;
 
-- -----------------------------------------------------
-- Table `test`.`marque`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`marque` (
  `id` INT NOT NULL ,
  `nom` VARCHAR(45) NULL ,
  PRIMARY KEY (`id`) )
ENGINE = InnoDB;
 
 
-- -----------------------------------------------------
-- Table `test`.`modele`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`modele` (
  `id` INT NOT NULL ,
  `titre` VARCHAR(45) NULL ,
  `marque_id` INT NOT NULL ,
  PRIMARY KEY (`id`) ,
  CONSTRAINT `fk_modele_marque`
    FOREIGN KEY (`marque_id` )
    REFERENCES `test`.`marque` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
 
CREATE INDEX `fk_modele_marque` ON `test`.`modele` (`marque_id` ASC) ;
 
 
-- -----------------------------------------------------
-- Table `test`.`rachat.php`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `test`.`rachat.php` (
  `idrachat.php` INT NOT NULL ,
  `trancheneuf1` VARCHAR(45) NULL ,
  `trancheneuf2` VARCHAR(45) NULL ,
  `tranchepropr1` VARCHAR(45) NULL ,
  `tranchepropr2` VARCHAR(45) NULL ,
  `tranchedelabr1` VARCHAR(45) NULL ,
  `tranchedelabre2` VARCHAR(45) NULL ,
  `tranchedefect1` VARCHAR(45) NULL ,
  `tranchedefect2` VARCHAR(45) NULL ,
  `modele_id` INT NOT NULL ,
  PRIMARY KEY (`idrachat.php`) ,
  CONSTRAINT `fk_rachat.php_modele1`
    FOREIGN KEY (`modele_id` )
    REFERENCES `test`.`modele` (`id` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;
 
CREATE INDEX `fk_rachat.php_modele1` ON `test`.`rachat.php` (`modele_id` ASC) ;
 
 
 
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
 
-- -----------------------------------------------------
-- Data for table `test`.`marque`
-- -----------------------------------------------------
START TRANSACTION;
USE `test`;
INSERT INTO `test`.`marque` (`id`, `nom`) VALUES (1, 'Samsung');
INSERT INTO `test`.`marque` (`id`, `nom`) VALUES (2, 'Htc');
INSERT INTO `test`.`marque` (`id`, `nom`) VALUES (3, 'Nokia');
INSERT INTO `test`.`marque` (`id`, `nom`) VALUES (4, 'Apple');
 
COMMIT;
 
-- -----------------------------------------------------
-- Data for table `test`.`modele`
-- -----------------------------------------------------
START TRANSACTION;
USE `test`;
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (1, 'Galaxy note', 1);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (2, 'Galaxy S2', 1);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (3, 'Player Star', 1);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (4, 'Desire', 2);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (5, 'DesireHD2', 2);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (6, 'Nexus one', 2);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (7, 'Lumia', 3);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (8, 'N97', 3);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (9, 'Iphone 4S', 4);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (10, 'Iphone 4', 4);
INSERT INTO `test`.`modele` (`id`, `titre`, `marque_id`) VALUES (11, 'Iphone 3GS', 4);
 
COMMIT;
 
-- -----------------------------------------------------
-- Data for table `test`.`rachat.php`
-- -----------------------------------------------------
START TRANSACTION;
USE `test`;
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (1, '350', '300', '300', '250', '200', '150', '130', '80', 1);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (2, '300', '280', '270', '230', '180', '130', '100', '50', 2);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (3, '100', '90', '90', '80', '70', '50', '40', '20', 3);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (4, '100', '90', '90', '80', '70', '50', '40', '20', 4);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (5, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 5);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (6, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 6);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (7, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 7);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (8, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 8);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (9, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 9);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 10);
INSERT INTO `test`.`rachat.php` (`idrachat.php`, `trancheneuf1`, `trancheneuf2`, `tranchepropr1`, `tranchepropr2`, `tranchedelabr1`, `tranchedelabre2`, `tranchedefect1`, `tranchedefect2`, `modele_id`) VALUES (11, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 11);
 
COMMIT;
et j'ai une liste liée qui fonctionne et un formulaire de bouton radio qui lui non ne fonctionne pas du moins si m'ai ce que je voudrais il ne le fait pas.
C'est a dire quand je sélectionne un marque puis un modèle et un état du téléphone je récupère tout mais pour ce qui est de l’état j'aurais aimé afficher selon l’état choisi et selon le téléphone une tranche de prix.
Et c'est la que sa coince je ne sais pas quel relation utilisé pour pouvoir liée les tranche au état!
voici mes pages.
auteurs.php
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
<html>
	<head>
		<title>My webpage is rich</title>
		<script type='text/javascript'>
 
			function getXhr(){
                            var xhr = null;
				if(window.XMLHttpRequest){ // Firefox et autres
				   xhr = new XMLHttpRequest(); 
 
				}
				else if(window.ActiveXObject){ // Internet Explorer 
				   try {
							xhr = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) {
							xhr = new ActiveXObject("Microsoft.XMLHTTP");
						}
				}
				else { // XMLHttpRequest non supporté par le navigateur 
				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
				   xhr = false; 
				} 
                            return xhr;
			}
 
 
 
			/**
			* Méthode qui sera appelée sur le click du bouton
			*/
			function change(){
 
				var xhr = getXhr();
 
				// On défini ce qu'on va faire quand on aura la réponse
				xhr.onreadystatechange = function(){
					//alert(xhr.readyState);
					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
					if(xhr.readyState == 4 && xhr.status == 200){
						di = document.getElementById('modele');
						di.innerHTML = xhr.responseText;
					}
				}
 
				// Ici on va voir comment faire du post
				xhr.open("POST","ajaxLivre.php",true);
				// ne pas oublier ça pour le post
				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				// ne pas oublier de poster les arguments
				// ici, l'id de l'auteur
				marque_id = document.getElementById('marque').options[document.getElementById('marque').selectedIndex].value;
				//alert(marque_id);
				xhr.send("marque_id="+marque_id);
 
 
			}
		</script>
	</head>
	<body>
		<form action="cible.php" method="post">
			<fieldset style="width: 500px">
				<legend>Liste liées</legend>
				<label>Marque</label>
				<select name='marque' id='marque' onchange='change()'>
					<option value='-1'>Choisir la marque</option>
					<?php
						mysql_connect("localhost","root","");
						mysql_select_db("test");
						$res = mysql_query("SELECT * FROM marque ");
						while($row = mysql_fetch_assoc($res)){
							echo "<option value='".$row["id"]."'>".$row["nom"]."</option>";
						}
					?>
 
				</select>
				<label>Modele</label>
				<div id='modele' style='display:inline'>
				<select name='modele'>
					<option value='-1'>Choisir le modele</option>
				</select>
				</div>
                <div id = 'etat' style='display:inline'>
                <p>
                  <label><br>
                    Selectionner un etat</label>
                </p>
                <p>                	
                  <input type="radio" name="etat1" value="Neuf" id="Neuf" checked="checked" /> 
                  <label for="Neuf">Neuf / Proche du neuf</label>
                </p>
                <p>	
                  <input type="radio" name="etat1" value="focntionel" id="focntionel" /> 
                  <label for="focntionel">Fonctionne</label>
                </p>
                 <p>	
                  <input type="radio" name="etat1" value="delabre" id="delabre" /> 
                  <label for="delabre">Delabrer</label>
                </p>
                 <p>	
                  <input type="radio" name="etat1" value="defect" id="defect" /> 
                  <label for="defect">Defectue</label>
 
                </p>
                </div>
          </fieldset>
            <input type="submit" value="Valider" />
		</form>
	</body>
</html>
ajaxLivre.php
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
<?php
 
	echo "<select name='modele'>";
	if(isset($_REQUEST["marque_id"])){
		mysql_connect("localhost","root","");
		mysql_select_db("test");
		$res = mysql_query("SELECT id,titre FROM modele WHERE marque_id=".$_REQUEST["marque_id"]." ORDER BY titre");
		while($row = mysql_fetch_assoc($res)){
			echo "<option value='".$row["titre"]."'>".$row["titre"]."</option>";
		}
	}
	else
		echo "<option value='-1'>Choisir le modele</option>";
	echo "</select>";
?>
Merci a tous!