
macweb
|
bonjour. j ai besoin de votre aide.je me nomme seb, webmaster design. je bricole un tout petit peu en php. j essaye de faire trois listes déroulantes liées. (type, marque, modèle) et de récupérer les valeurs. pour l affichage de deux pas de soucis mais trois ça bloque.
voici ma page d affichage
<?php
$co=mysql_connect("mysql5-13.xxl","tribespolink","joExKE9n");
$dbnom="tribespolink";
$db=mysql_select_db($dbnom,$co);
//==========================================
//== on affiche dans un select la TABLE 1 ==
//==========================================
$res=mysql_query("SELECT * FROM tabl1",$co);
$max=@mysql_num_rows($res);
?>
<script type="text/javascript">
function xmlhttp()
{ var x;
try { x = new ActiveXObject("Microsoft.XMLHTTP"); }
catch (e) { try { x = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e) { try { x = new XMLHttpRequest(); }
catch (e) { x=false; }
}
}
return x;
}
function appel()
{ var xml = xmlhttp();
if(!xml)
{ alert("XmlHttpRequest non supporté"); }
else { xml.onreadystatechange = function()
{ if(xml.readyState==4)
{ var opt=xml.responseText.split("\t");
tb2.length=0;
for ( var n=1;n<opt.length;n++ )
{ tb2.length++;
tb2.options[tb2.length-1].text=opt[n];
}
}
}
xml.open("GET", "Ajax2.php?tbl2="+tb1.options[tb1.selectedIndex].text, true);
xml.send(null);
}
}
</script>
<select name="tb1" id="tb1"
size=1
onchange='appel();'><?php
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"t1ind");
echo '<option>'.$i.'</option>';
}
?>
</select>
<select name="tb2" id="tb2"
size=1>
</select>
<select name="tb3" id="tb3"
size=1>
</select>
<?php
mysql_close($co);
?>
ma page d appel pour le deuxième menu
<?php
header('Content-type:text/html;charset=ISO-8859-1');
$co=mysql_connect("mysql5-13.xxl","tribespolink","joExKE9n");
$dbnom="tribespolink";
$db=mysql_select_db($dbnom,$co);
$rch="WHERE t2t1ind='".$_GET["tbl2"]."'";
$res=mysql_query("SELECT * FROM tabl2 ".$rch,$co);
$max=@mysql_num_rows($res);
$t="";
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"t2ind");
$a.="\t".$i;
}
echo $a;
mysql_close($co);
?>
ma page d appel pour le troisième
<?php
header('Content-type:text/html;charset=ISO-8859-1');
$co=mysql_connect("mysql5-13.xxl","tribespolink","joExKE9n");
$dbnom="tribespolink";
$db=mysql_select_db($dbnom,$co);
$rch="WHERE t3t2ind='".$_GET["tbl3"]."'";
$res=mysql_query("SELECT * FROM tabl3 ".$rch,$co);
$max=@mysql_num_rows($res);
$t="";
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"t3ind");
$t.="\t".$i;
}
echo $t;
mysql_close($co);
?>
et voici ma base de données
-- Base de données: `tribespolink`
--
-- --------------------------------------------------------
--
-- Structure de la table `tabl1`
--
CREATE TABLE IF NOT EXISTS `tabl1` (
`t1ind` char(20) NOT NULL,
PRIMARY KEY (`t1ind`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Contenu de la table `tabl1`
--
INSERT INTO `tabl1` (`t1ind`) VALUES
('----'),
('moto'),
('quad'),
('ssv');
-- --------------------------------------------------------
--
-- Structure de la table `tabl2`
--
CREATE TABLE IF NOT EXISTS `tabl2` (
`t2t1ind` char(20) NOT NULL,
`t2ind` char(20) NOT NULL,
PRIMARY KEY (`t2t1ind`,`t2ind`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Contenu de la table `tabl2`
--
INSERT INTO `tabl2` (`t2t1ind`, `t2ind`) VALUES
('moto', '----'),
('moto', 'beta'),
('moto', 'bmw'),
('moto', 'gasgas'),
('moto', 'honda'),
('moto', 'husaberg'),
('moto', 'husqvarna'),
('moto', 'kawasaki'),
('moto', 'ktm'),
('moto', 'suzuki'),
('moto', 'yamaha'),
('quad', '----'),
('quad', '-bombardier-'),
('quad', '-can am-'),
('quad', '-honda-'),
('quad', '-kawasaki-'),
('quad', '-ktm-'),
('quad', '-polaris-'),
('quad', '-suzuki-'),
('quad', '-yamaha-'),
('ssv', '----'),
('ssv', '_artic cat_'),
('ssv', '_honda_'),
('ssv', '_kawasaki_'),
('ssv', '_polaris_'),
('ssv', '_yamaha_');
-- --------------------------------------------------------
--
-- Structure de la table `tabl3`
--
CREATE TABLE IF NOT EXISTS `tabl3` (
`t3t2ind` varchar(255) NOT NULL,
`t3ind` varchar(255) NOT NULL,
FULLTEXT KEY `t3t2ind` (`t3t2ind`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
-- Contenu de la table `tabl3`
--
INSERT INTO `tabl3` (`t3t2ind`, `t3ind`) VALUES
('honda', 'cr125'),
('honda', 'cr250'),
('yamaha', 'yz125'),
('yamaha', 'yz250'),
('-honda-', 'duchmol'),
('-yamaha-', 'blaster');
. si quelque un peu m aider.....MERCI
|