merci delete,
en faite j'ai réussi a faire ce que je voulais par contre c'est loin d'être à la mode oscommerce
voila comment j'ai procédé pour affiché une liste déroulante avec les numéro de commande qui une fois sélectionné renvoie les articles de cette commande
En php:
<h1>test liste liée</h1>
<?php //require('includes/application_top.php');?>
<form method="post">
<select name="orders" id="orders"
size=3
onchange='appel();'>
<?php
$connexion=mysql_connect("localhost","user","pass");
$dbnom="Ma_table";
$db=mysql_select_db($dbnom,$connexion);
//==========================================
//== on affiche dans un select la TABLE 1 ==
//==========================================
$res=mysql_query("SELECT * FROM orders",$connexion);
$max=@mysql_num_rows($res);
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"orders_id");
if ( isset($_POST["orders_id"]) && $_POST["orders_id"]==$i )
$s=' selected';
else $s='';
echo '<option'.$s.' value="'.$i.'">'.$i.'</option>';
}
?>
</select>
<?php
if (isset($_POST["orders"])) {
//==========================================
//== on affiche dans un select la TABLE 2 ==
//==========================================
?>
<select name="orders_products" id="orders_products"
size=3>
<?php
$rch="WHERE orders_id='".$_POST["orders"]."'";
$res=mysql_query("SELECT * FROM orders_products ".$rch,$connexion);
$max=@mysql_num_rows($res);
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"products_name");
echo '<option value="'.$i.'">'.$i.'</option>';
}
?>
</select>
<?php }
mysql_close($connexion);
?>
<input type="submit" />
</form>
On peux aussi le faire en ajax (c'est même mieux )pour sa il faut par contre un 2ème fichier:
1er fichier
<?php
$connexion=mysql_connect("localhost","user","pass");
$dbnom="Ma_table";
$db=mysql_select_db($dbnom,$connexion);
//==========================================
//== on affiche dans un select la TABLE 1 ==
//==========================================
$res=mysql_query("SELECT * FROM orders",$connexion);
$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");
orders_products.length=0;
for ( var n=1;n<opt.length;n++ )
{ orders_products.length++;
orders_products.options[orders_products.length-1].text=opt[n];
}
}
}
xml.open("GET", "Ajax2.php?tbl2="+orders.options[orders.selectedIndex].text, true);
xml.send(null);
}
}
</script>
<select name="orders" id="orders"
size=3
onchange='appel();'><?php
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"orders_id");
echo '<option>'.$i.'</option>';
}
?>
</select>
<select name="orders_products" id="orders_products"
size=3>
</select>
<?php
mysql_close($connexion);
?>
2ème fichier:
<?php
header('Content-type:text/html;charset=ISO-8859-1');
$connexion=mysql_connect("localhost","user","pass");
$dbnom="Ma_table";
$db=mysql_select_db($dbnom,$connexion);
$rch="WHERE orders_id='".$_GET["tbl2"]."'";
$res=mysql_query("SELECT * FROM orders_products ".$rch,$connexion);
$max=@mysql_num_rows($res);
$t="";
for ($nb=0;$nb<$max;$nb++)
{ $i=mysql_result($res,$nb,"products_name");
$t.="\t".$i;
}
echo $t;
mysql_close($connexion);
?>
Ce code fonctionne assez bien maintenant il me reste à l'arranger façon oscommerce pour que sa soit correct mais je vois vraiment pas comment intégrer le javascript à un tep_draw_pull_down_menu par exemple :unsure:
En cherchant je vais bien trouver de toute façon mais l'aide est toujours la bienvenue, y'a encore du boulot j'aimerais bien faire une petite gestion coté admin après :Rofl: