soucis order by :'(
Posté : 31 août 2008, 21:19
Bonjour je debute en php et la j ai du mal
j ai essayé tout un tas de chose mais rien ne marche j aimerai pouvoir trier mes resultats par "peremption" des l affichage de la page.
Voici le code
Merci de votre aide car meme si pour vous c est probablement evident, pour moi c est la galere lol
Voici le code
Code : Tout sélectionner
<?
$connexion = mysql_connect("localhost","root","")
or die ("probleme de connection");
$db = mysql_select_db("chimie",$connexion)
or die ("probleme de selection de base de donnée");
$link="SELECT prod FROM month" ;
$result = mysql_query($link);
$num_rows = mysql_num_rows($result);
$num=$num_rows+1;
?>
<center>
<table border="1" cellspacing="1" cellpadding="1">
<tr bordercolor="#FF9900" align='center'>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Categorie</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Designation</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Reference</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Marque</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Unite de vente</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>peremption</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Stock</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Information complementaire 1</b></th>
<th width="116" bgcolor="#FFCC99" scope="col"><b>Information complementaire 2</b></th>
</tr><?
for ($i=1;$i<$num;$i++)
{
$query = mysql_query("SELECT prod, quant, temp1, peremption, temp3, temp4, temp5, temp6, temp7 FROM stock WHERE ID='$i' ORDER BY peremption");
$data = mysql_fetch_array($query, MYSQL_ASSOC);
$prod=$data['prod'];
$quant=$data['quant'];
$temp1=$data['temp1'];
$peremption=$data['peremption'];
$temp3=$data['temp3'];
$temp4=$data['temp4'];
$temp5=$data['temp5'];
$temp6=$data['temp6'];
$temp7=$data['temp7'];
{
$fin=$prod;
$a=strlen($prod);
for ($f=1;$f<$a;$f++)
{
$une=$prod{0};
if ($une=="_")
{
$b=$f-1;
}
$prod=substr($prod,1);
}
$prod=substr($fin,0,$b);
?>
<tr bordercolor="#FF9900" align='center'>
<td bgcolor="#FFCC99"><? echo "$temp3";?></td>
<td bgcolor="#FFCC99"><? echo "$prod";?></td>
<td bgcolor="#FFCC99"><? echo "$temp1";?></td>
<td bgcolor="#FFCC99"><? echo "$temp4";?></td>
<td bgcolor="#FFCC99"><? echo "$temp5";?></td>
<td bgcolor="#FFCC99"><? echo "$peremption";?></td>
<td bgcolor="#FFCC99"><? echo "$quant";?></td>
<td bgcolor="#FFCC99"><? echo "$temp6";?></td>
<td bgcolor="#FFCC99"><? echo "$temp7";?></td>
</tr>
<?
}
}
?>
</table>
</center>
</body>
</html>