interroger une bdd via une page web
Salut a tous ,
Je suis nouveau sur ce forum , et la programmation n'est pas mon fort .
Voici mon probléme je souhaite interroger une BDD via une page web , je m'explique on arrive sur une page nommé " essai.htm " on nous demande de rentrer une référence a 7 chiffres cette page nous redirige vers une page nommé " search.php3 " qui s'occupe de se connecter a la base , d'executer la requete sql en fonction de la référence entré auparavant .
Code de la page search.php3
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
| <html>
<head>
<title>Stock par magasins</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
$link = mysql_connect("localhost","root","");//connexion local
mysql_select_db("bata",$link);
$query = " select num_art,num_mag,type_grille,total_stock,stockpt1,stockpt2,stockpt3,stockpt4,stockpt5,stockpt6,stockpt7,stockpt8,stockpt9,stockpt10,stockpt11,stockpt12,stockpt13,stockpt14 from articles,magasins,stock,grille where
stock.magasin = magasins.num_mag AND stock.ref_art = articles.num_art AND articles.grille_art=grille.type_grille AND num_art = ".$_POST["num_art"];
//.$_POST["num_mag"];
//.$_POST["num_art"];
$result = mysql_query($query,$link);//on interroge la base
$html = "<table width='30%' border='1'><tr>
<td width='20%'><b><font color=red>Articles</font></b></td>
<td width='20%'><b><font color=red>Magasins</font></b></td>
<td width='20%'><b><font color=red>grille</font></b></td>
<td width='20%'><b><font color=#FF0000>Stock total</font></b></td>
<td width='20%'><b><font color=red>stockpt1</font></b></td>
<td width='20%'><b><font color=red>Stockpt2</font></b></td>
<td width='20%'><b><font color=red>Stockpt3</font></b></td>
<td width='20%'><b><font color=red>Stockpt4</font></b></td>
<td width='20%'><b><font color=red>Stockpt5</font></b></td>
<td width='20%'><b><font color=red>Stockpt6</font></b></td>
<td width='20%'><b><font color=red>Stockpt7</font></b></td>
<td width='20%'><b><font color=red>Stockpt8</font></b></td>
<td width='20%'><b><font color=red>Stockpt9</font></b></td>
<td width='20%'><b><font color=red>Stockpt10</font></b></td>
<td width='20%'><b><font color=red>Stockpt11</font></b></td>
<td width='20%'><b><font color=red>Stockpt12</font></b></td>
<td width='20%'><b><font color=red>Stockpt13</font></b></td>
<td width='20%'><b><font color=red>Stockpt14</font></b></td>
</tr>";
while ($row = mysql_fetch_array($result)){
$html .= "<tr>
<td>".$row["num_art"]."</td>
<td>".$row["num_mag"]."</td>
<td>".$row["type_grille"]."</td>
<td>".$row["total_stock"]."</td>
<td>".$row["stockpt1"]."</td>
<td>".$row["stockpt2"]."</td>
<td>".$row["stockpt3"]."</td>
<td>".$row["stockpt4"]."</td>
<td>".$row["stockpt5"]."</td>
<td>".$row["stockpt6"]."</td>
<td>".$row["stockpt7"]."</td>
<td>".$row["stockpt8"]."</td>
<td>".$row["stockpt9"]."</td>
<td>".$row["stockpt10"]."</td>
<td>".$row["stockpt11"]."</td>
<td>".$row["stockpt12"]."</td>
<td>".$row["stockpt13"]."</td>
<td>".$row["stockpt14"]."</td>
</tr>";
}
$html .= "</table>";
echo $html; //On affiche la variable $html
mysql_free_result($result);
mysql_close($link);//on se d�connecte
?>
</body>
</html> |
partie du code essai.htm
Code:
1 2 3 4 5 6 7 8 9 10
| <div align="center"><form method="post" action="search.php3">
<br>
Entrez un num�ro d'article : <input type="text" name="num_art" size="7" id="num_art" maxlength="7"><br>
<input type="submit" value="Rechercher" alt="Lancer la recherche!">
</form></div> |
Voici ce que j'obtiens :
Code:
Articles Magasins grille Stock total stockpt1 Stockpt2 Stockpt3 Stockpt4 Stockpt5 Stockpt6 Stockpt7 Stockpt8 Stockpt9 Stockpt10 Stockpt11 Stockpt12 Stockpt13 Stockpt14 "; while ($row = mysql_fetch_array($result)){ $html .= " ".$row["num_art"]." ".$row["num_mag"]." ".$row["type_grille"]." ".$row["total_stock"]." ".$row["stockpt1"]." ".$row["stockpt2"]." ".$row["stockpt3"]." ".$row["stockpt4"]." ".$row["stockpt5"]." ".$row["stockpt6"]." ".$row["stockpt7"]." ".$row["stockpt8"]." ".$row["stockpt9"]." ".$row["stockpt10"]." ".$row["stockpt11"]." ".$row["stockpt12"]." ".$row["stockpt13"]." ".$row["stockpt14"]." "; } $html .= ""; echo $html; //On affiche la variable $html mysql_free_result($result); mysql_close($link);//on se d�connecte ?>
Je ne demande pas forcement de résoudre mon probléme mais des éléments de réponse qui puissent m'aider a comprendre . :mur:
Sans oublier je suis sur fedora core 6 et j'utilise PhpMyAdmin
Merci d'avance .