par
Kimble » 24 déc. 2005, 12:02
Me revoilà, j'ai refais quelques trucs...
Comme on dit dans la police "reprenons depuis le début"...
index.php simplifié :
<?php include("connexion.php");
include("fonctions_ventes.php");
$liste=(isset($_GET['liste'])) ? $_GET['liste'] : "";
//commercial à traiter
$com=(isset($_POST['com'])) ? $_POST['com'] : "";
<li><?php afficher_url("index.php?liste=ventes","Voir toutes les ventes"); ?></li>
<?php
switch($liste)
{
case'commercial_ventes':
include("commercial_ventes.php");
break;
}?>
cookie_commercial.php
<?php
setcookie( 'rowsPerPage', $_POST[ 'rowsPerPage' ], time()+999999 );
$commer = isset($_GET['com_choisi']) ? $_GET['com_choisi'] : '';
?>
<html>
<head>
<title></title>
<meta http-equiv="REFRESH" content="0;url=index.php?liste=commercial_ventes&choix=commercial&com_choisi=<?php $commer['com_choisi']?>;">
</head>
<body>
</body>
</html>
commercial_ventes.php simplifié
<?php
$choix=(isset($_GET['choix'])) ? $_GET['choix'] : "";
$com_choisi=(isset($_GET['com_choisi'])) ? $_GET['com_choisi'] : "";
//les donnees pour le cookie et la barre de navigation
$query = mysql_query( "SELECT idcommercial FROM vente, commercial WHERE id_commercial LIKE '$com_choisi'" ); //query the table
$numrows = mysql_num_rows( $query ); //how many rows will be fetched?
$nb_results_p_page = isset( $_COOKIE[ 'rowsPerPage' ] ) ? $_COOKIE[ 'rowsPerPage' ] : 7; //Par defaut affichage de 7 ventes
if( $numrows > $nb_results_p_page ) //do we need to break output into pages?
{
$page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : 0; //load specified page number (set to 1 if not specified)
if( $numrows % $nb_results_p_page )
$maxpage = floor( $numrows / $nb_results_p_page ) +1;
else
$maxpage = $numrows / $nb_results_p_page; //get maximum page number
if( $page > $maxpage ) $page = 1; //if out of range, set to deafult (page 1)
$limit = " LIMIT " . ( ( $page - 1 ) * $nb_results_p_page ) . "," . $nb_results_p_page; //make LIMIT offset,rowcount string
$query = mysql_query( "SELECT * FROM vente ORDER BY client $limit" ); //and set query to include the LIMIT string
}
//$nb_results_p_page = 7; // nombre de résultats par page que j'ai mis en silence
$nb_avant = 2; // nombre de page avant la page courante
$nb_apres = 2; // nombre de page après la page courante
$premiere = 1; // aficher le lien "première page" (1 ou 0)
$derniere = 1; // afficher le lien "dernière page" (1 ou 0)
$courant = empty($_GET['page']) ? 1 : $_GET['page']; // page
$start = ($courant - 1) * $nb_results_p_page; // start (requete mysql)
// comptage du nombre de lignes de la table
$query = mysql_query("SELECT COUNT(idcommercial) FROM vente WHERE idcommercial LIKE '$com_choisi'");
if(!$query)
{
// redirection erreur
header("location: erreur.php");
exit;
}
$ret = mysql_fetch_array($query);
// nombre de lignes
$nb_results = $ret[0];
$result = mysql_query ("select * from vente where idcommercial LIKE '$com_choisi' ORDER BY client asc LIMIT $start, $nb_results_p_page");?>
<?php //le formulaire qui appelle le cookie ?>
<form action="cookie_commercial.php" method="POST">
<strong>Afficher</strong>
<input name="rowsPerPage" type="radio" value="7" checked="checked"> <strong>7</strong>
<input name="rowsPerPage" type="radio" value="20"> <strong>20</strong>
<input name="rowsPerPage" type="radio" value="50"> <strong>50</strong>
<input name="rowsPerPage" type="radio" value="100"> <strong>100 </strong>
<input type="submit" class='bouton' value="Ventes" />
</form>
<?php //l'entete du tableau?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="center" bgcolor="#FFCC66"><span class="Style3">Co.</span></td>
<?php //Le while
while ($vente=mysql_fetch_array($result))
{
//affichage des donnees
<?php
$com=$vente['idcommercial'];
$req_commer=mysql_query("select * from commercial where id_commercial='$com'");
$commer=mysql_fetch_array($req_commer);
$lien="index.php?liste=commercial_ventes&choix=commercial&com_choisi=".$commer['id_commercial'];
afficher_url($lien,"<img src=\"images/com.gif\" width=\"21\" height=\"21\" border=\"0\"alt=\" Voir les ventes de ".$commer['commercial']." \">");?>
</span></td>
La suite c'est la fin de la barre de navigation.
J'espére que je n'ai rien oublié.
Me revoilà, j'ai refais quelques trucs...
Comme on dit dans la police "reprenons depuis le début"...
:D
index.php simplifié :
[php]
<?php include("connexion.php");
include("fonctions_ventes.php");
$liste=(isset($_GET['liste'])) ? $_GET['liste'] : "";
//commercial à traiter
$com=(isset($_POST['com'])) ? $_POST['com'] : "";
<li><?php afficher_url("index.php?liste=ventes","Voir toutes les ventes"); ?></li>
<?php
switch($liste)
{
case'commercial_ventes':
include("commercial_ventes.php");
break;
}?>[/php]
cookie_commercial.php
[php]<?php
setcookie( 'rowsPerPage', $_POST[ 'rowsPerPage' ], time()+999999 );
$commer = isset($_GET['com_choisi']) ? $_GET['com_choisi'] : '';
?>
<html>
<head>
<title></title>
<meta http-equiv="REFRESH" content="0;url=index.php?liste=commercial_ventes&choix=commercial&com_choisi=<?php $commer['com_choisi']?>;">
</head>
<body>
</body>
</html> [/php]
commercial_ventes.php simplifié
[php]
<?php
$choix=(isset($_GET['choix'])) ? $_GET['choix'] : "";
$com_choisi=(isset($_GET['com_choisi'])) ? $_GET['com_choisi'] : "";
//les donnees pour le cookie et la barre de navigation
$query = mysql_query( "SELECT idcommercial FROM vente, commercial WHERE id_commercial LIKE '$com_choisi'" ); //query the table
$numrows = mysql_num_rows( $query ); //how many rows will be fetched?
$nb_results_p_page = isset( $_COOKIE[ 'rowsPerPage' ] ) ? $_COOKIE[ 'rowsPerPage' ] : 7; //Par defaut affichage de 7 ventes
if( $numrows > $nb_results_p_page ) //do we need to break output into pages?
{
$page = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : 0; //load specified page number (set to 1 if not specified)
if( $numrows % $nb_results_p_page )
$maxpage = floor( $numrows / $nb_results_p_page ) +1;
else
$maxpage = $numrows / $nb_results_p_page; //get maximum page number
if( $page > $maxpage ) $page = 1; //if out of range, set to deafult (page 1)
$limit = " LIMIT " . ( ( $page - 1 ) * $nb_results_p_page ) . "," . $nb_results_p_page; //make LIMIT offset,rowcount string
$query = mysql_query( "SELECT * FROM vente ORDER BY client $limit" ); //and set query to include the LIMIT string
}
//$nb_results_p_page = 7; // nombre de résultats par page que j'ai mis en silence
$nb_avant = 2; // nombre de page avant la page courante
$nb_apres = 2; // nombre de page après la page courante
$premiere = 1; // aficher le lien "première page" (1 ou 0)
$derniere = 1; // afficher le lien "dernière page" (1 ou 0)
$courant = empty($_GET['page']) ? 1 : $_GET['page']; // page
$start = ($courant - 1) * $nb_results_p_page; // start (requete mysql)
// comptage du nombre de lignes de la table
$query = mysql_query("SELECT COUNT(idcommercial) FROM vente WHERE idcommercial LIKE '$com_choisi'");
if(!$query)
{
// redirection erreur
header("location: erreur.php");
exit;
}
$ret = mysql_fetch_array($query);
// nombre de lignes
$nb_results = $ret[0];
$result = mysql_query ("select * from vente where idcommercial LIKE '$com_choisi' ORDER BY client asc LIMIT $start, $nb_results_p_page");?>
<?php //le formulaire qui appelle le cookie ?>
<form action="cookie_commercial.php" method="POST">
<strong>Afficher</strong>
<input name="rowsPerPage" type="radio" value="7" checked="checked"> <strong>7</strong>
<input name="rowsPerPage" type="radio" value="20"> <strong>20</strong>
<input name="rowsPerPage" type="radio" value="50"> <strong>50</strong>
<input name="rowsPerPage" type="radio" value="100"> <strong>100 </strong>
<input type="submit" class='bouton' value="Ventes" />
</form>
<?php //l'entete du tableau?>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td align="center" bgcolor="#FFCC66"><span class="Style3">Co.</span></td>
<?php //Le while
while ($vente=mysql_fetch_array($result))
{
//affichage des donnees
<?php
$com=$vente['idcommercial'];
$req_commer=mysql_query("select * from commercial where id_commercial='$com'");
$commer=mysql_fetch_array($req_commer);
$lien="index.php?liste=commercial_ventes&choix=commercial&com_choisi=".$commer['id_commercial'];
afficher_url($lien,"<img src=\"images/com.gif\" width=\"21\" height=\"21\" border=\"0\"alt=\" Voir les ventes de ".$commer['commercial']." \">");?>
</span></td>
[/php]
La suite c'est la fin de la barre de navigation.
J'espére que je n'ai rien oublié.