bonjour

je suis débutant et j'ai un problème de requête avec une pagination

cela fait plusieurs jours que je tente plusieurs solution mais sans résultat

pouvez m'aider et me conseiller.

voici le bout de code

je suis désoler par avance si le code n'est pas afficher en BBcode je n'est pas trouvez la fonction.

page 1

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
 
<?php
require_once("pagination_new_test_opt.php");
?>
 
 
<!-- CHERCHER PAR THEME -->
<form id="form1" name="form1" method="get" action="<?php  echo $_SERVER['PHP_SELF']."#playliste"; ?>">
  	<select name="themeziq" id="themeziq" onChange="form1.submit();">
 
  		<?php while($themeziq_aff=mysql_fetch_assoc($resultat2))  { ?>
   			 <option <?php  if(!isset($_GET['themeziq'])) $_GET['themeziq']=1; if($themeziq_aff['ID']==$_GET['themeziq'] ) echo  "selected='selected'"; ?> value="<?php echo $themeziq_aff['ID']; ?>"><?php echo $themeziq_aff['typezik']; ?></option>
  		<?php } ?>
		<input type="submit"  name="oksub" value="ok">
  	</select>
</form>
 
<br/>
<?php if(isset($affihchage_select_them)){ echo $affihchage_select_them ; }?>
 
<table class="PhorumStdTable" border="0" cellspacing="0" cellpadding="0"  bgcolor='<?php $bgcolor ?>' >
	<tr>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="20">N°</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="10">New</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="30">Séquence Titre</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="30">Bpm</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="100">Thème musical</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="100">Écoute et t&eacute;l&eacute;chargement</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="150">Nombre de t&eacute;l&eacute;chargement</th>
		<th class="PhorumTableHeader" align="center" nowrap="nowrap" width="150">Compositeur</th>
		<!-- <td style="background-color : transparent;">id</td> frame="void" rules="cols"  -->
	</tr>
 
	<?php
 
	while ( $donnee = mysql_fetch_assoc($resultat)) {
 
		// $id = $donnee['id'];
 
		// if($id%2)
			// $bgcolor = '#FFFFFF';
		// else
			// $bgcolor = '#333333';
	?>
 
	<tr >
		<td class="PhorumTableRow" align="center" >
			<i><?php echo $donnee['id']; ?></i>
		</td>
		<td class="PhorumTableRow" align="center" nowrap="nowrap">
			<img src="<?php  echo $donnee['id_nouveaute_img']; ?>" width="41"  height="15px" border="0" alt="audio_icon.gif"/>
		</td>
		<td class="PhorumTableRow" align="center" nowrap="nowrap"><a href="javascript:<?php echo $donnee['var']; ?>" ><b><?php echo $donnee['titre']; ?></a></b></td>
		<td class="PhorumTableRow" align="center"  nowrap="nowrap"><?php echo $donnee['bpm']; ?></td>
		<td class="PhorumTableRow" align="center"  nowrap="nowrap"><i><?php echo $donnee['typezik']; ?></i></td>
		<td class="PhorumTableRow" align="center"  nowrap="nowrap">
			<div  class="meedles_play_compo">
				<table>
					<tr>
						<td valign="top">
							<img src="img_PHPpagesSite/design/audio_icon.gif" width="100%"  height="20px" border="0" alt="audio_icon.gif"/>
						</td>
						<td valign="bottom">
							<a href="javascript:setSndTrack('<?php echo $donnee['description']; ?>');" id='mp3_file' name='mp3_son' onclick="javascript:vumetre_play();<?php echo $donnee['var']; ?>" ><b>Play</b></a>
							 |
							<a href="javascript:setSndTrack('stop');" id='mp3_file' name='mp3_son' onclick="javascript:vumetre_stop()" ><b>stop</b></a></p>
						</td>
						<td valign="top">
							<a href="comptreur_down/index.php?mod=livre&id=<?php echo $donnee['id']; ?>#playliste"><img src="img_PHPpagesSite/design/download.png" width="100%"  height="20px" border="0" title="T&eacute;l&eacute;charger : <?php echo $donnee['titre']; ?>.mp3" alt="audio_icon.gif"/></a>
						</td>
						<td valign="top">
						</td>
						<td valign="top">
							<b>0</b> &euro;
						</td>
					</tr>
				</table>
			</div>
		</td>
		<td class="PhorumTableRow" align="center"  nowrap="nowrap"><?php echo $donnee['count']; ?></td>
		<td class="PhorumTableRow PhorumSmallFont" nowrap="nowrap">
			<?php echo $donnee['date']; ?> Ã* <?php echo $donnee['time']; ?>&nbsp;<br>
			<span class="PhorumListSubText">
			  Créer par : <a href=""><?php echo $donnee['compositeurscrew']; ?></a></span>
		</td>	
 
	</tr>
 
	<?php } ?>
</table>
 
<?php
 
 // if(isset($_GET['themeziq']) == "pagevu"&& isset($_GET['pagevu']) == "ok"){
 if( isset($pagetestz) == 10 ) {
$sql = mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die (mysql_error().' sur la ligne '.__LINE__);
mysql_select_db(DB_BDDTest);
 
$pagetestzvu = 1;
 
$nb_totalx = mysql_query('SELECT COUNT(*) AS nb_totalx FROM 
compositeurs AS a
INNER JOIN compositeurs_style_zik AS f   ON  a.userid="'.$_GET['themeziq'].'"
WHERE f.ID="'.$_GET['themeziq'].'"

');
$nb_totalx = mysql_fetch_assoc($nb_totalx);
$nb_totalx = $nb_totalx['nb_totalx'];
 
mysql_close ($sql) ;
 
/*
if (mysql_close ($sql))

    echo "<br/><br/>The connection nb_total+themeziq  pagin was closed.";
else
    echo "<br/><br/>The connection nb_total+themeziq  pagincould not be closed.";
*/
 
// Pagination
 $nb_pagesx = ceil($nb_totalx / $paginationx);
// Affichage
echo '<div class="pagination" align="center">' . paginationx($pagevu, $nb_pagesx) . '<br/>';
echo 'page <strong> ' . $pagevu. ' </strong>/ ' . $nb_pagesx . ' &raquo;Total theme d\'instru :<strong>' . $nb_totalx. '</strong> </div>';
//mysql_close();
}
else{
 
 if( $pagetestzvu == '' ){
 
// CONNEXION À LA BD
$sql = mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die (mysql_error().' sur la ligne '.__LINE__);
mysql_select_db(DB_BDDTest);
 
 
// Nb d'enregistrement total
$nb_total = mysql_query('SELECT COUNT(*) AS nb_total FROM compositeurs');
$nb_total = mysql_fetch_assoc($nb_total);
$nb_total = $nb_total['nb_total'];
 
mysql_close ($sql) ;
 
/*
if (mysql_close ($sql))

    echo "<br/><br/>The connection nb_total+compositeurs pagin was closed.";
else
    echo "<br/><br/>The connection nb_total+compositeurs pagin  could not be closed.";
*/
 
// Pagination
 $nb_pages = ceil($nb_total / $pagination);
// Affichage
echo '<div class="pagination" align="center">' . pagination($page, $nb_pages) . '<br/>';
echo 'page <strong> ' . $page. ' </strong>/ ' . $nb_pages . ' &raquo;Total d\'instru :<strong>' . $nb_total. '</strong> </div>';
//mysql_close();
 
}
} 
// Pagination
/* $nb_pages = ceil($nb_total / $pagination);
// Affichage
echo '<div class="pagination" align="center">' . pagination($page, $nb_pages) . '<br/>';
echo 'page <strong> ' . $page. ' </strong>/ ' . $nb_pages . ' &raquo;Total d\'instru :<strong>' . $nb_total. '</strong> </div>';
 */?>
page 2

pagination

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
 
if(isset($_GET['themeziq']) ){
 
	// Numero de page (1 par défaut)
	if( isset($_GET['pagevu']) && is_numeric($_GET['pagevu']) && $_GET['themeziq']) {
	    $pagevu = $_GET['pagevu'];
	     $pagetestz = 10;
	    // $pagetest;
	}else{
	    $pagetestz = 10;
	    // if( isset($_GET['pagevu']) == "pagevu" 
 
	    $pagevu = 1;
 
	// Nombre d'info par page
	$paginationx = 1;
 
	// Numéro du 1er enregistrement Ã* lire
	$limit_startx = ($pagevu - 1) * $paginationx;
 
// CONNEXION À LA BD
$sql = mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die (mysql_error().' sur la ligne '.__LINE__);
mysql_select_db(DB_BDDTest);
	$requete2="
	SELECT a.*, f.typezik, n.id_nouveaute_img, c.compositeurscrew
	FROM  compositeurs AS a
	INNER JOIN compositeurs_style_zik AS f   ON  a.userid=".$_GET['themeziq']."
        LEFT JOIN compositeurs_real AS c  ON a.IDcompositeur=c.ID
		LEFT JOIN compositeurs_nouveaute AS n  ON a.id_nouveaute= n.ID
	WHERE f.ID=".$_GET['themeziq']."  ORDER BY id DESC LIMIT $limit_startx, $paginationx";
    $resultat = mysql_query($requete2);
 
 
 	$result_aff="
	SELECT a.userid, f.typezik, n.id_nouveaute_img, c.compositeurscrew
	FROM  compositeurs AS a
	INNER JOIN compositeurs_style_zik AS f   ON  a.userid=".$_GET['themeziq']."
        LEFT JOIN compositeurs_real AS c  ON a.IDcompositeur=c.ID
		LEFT JOIN compositeurs_nouveaute AS n  ON a.id_nouveaute= n.ID
	WHERE f.ID=".$_GET['themeziq']." AND  a.userid=".$_GET['themeziq']." ";
 
  $resultat_aff = mysql_query($result_aff);
	$resultat_affa = mysql_fetch_assoc($resultat_aff);
	$affihchage_select_them = "Rubrique sélectionné : Thème musical &raquo; [ &ndash; " .$resultat_affa['typezik']." &ndash; ] ";
 
 
 
 
 }
 }
else {	
 
	// Numero de page (1 par défaut)
	if( isset($_GET['page']) && is_numeric($_GET['page']) )
	    $page = $_GET['page'];
	    // $pagetestz = 15;
	else
	    $page = 1;
	    // $pagetestz = 15;
 
	// Nombre d'info par page
	$pagination = 6;
 
	// Numéro du 1er enregistrement Ã* lire
	$limit_start = ($page - 1) * $pagination;
 
// CONNEXION À LA BD
$sql = mysql_connect(DB_HOST,DB_LOGIN,DB_PASS) or die (mysql_error().' sur la ligne '.__LINE__);
mysql_select_db(DB_BDDTest);
 
 
	$sql_pagine="
	SELECT a.id, a.compositeurs, a.titre, a.description, a.bpm, a.nouveaute, a.count, a.var, a.cover, a.date, a.time,
	f.typezik, n.id_nouveaute_img, i.compositeurscrew
	FROM  compositeurs AS a
	INNER JOIN compositeurs_style_zik AS f  ON a.userid=f.ID
	
	LEFT JOIN compositeurs_real AS i ON a.IDcompositeur= i.ID

	LEFT JOIN compositeurs_nouveaute AS n ON a.id_nouveaute= n.ID
	ORDER BY id DESC LIMIT $limit_start, $pagination ";
 
 
	mysql_query('SET NAMES UTF8');
 
 
	// Requête SQL
	$resultat = mysql_query($sql_pagine);
 
 /*
if (mysql_close ($sql))

    echo "<br/><br/>The connection S_GET['page'] was closed.";
else
    echo "<br/><br/>The connection S_GET['page'] wcould not be closed.";

    */
}
 
	/* mysql_close($sql); */
 
 
 
 
 
/*-------------------------------------------------*/
 
function pagination($current_page, $nb_pages, $link='?page=%d', $around=3, $firstlast=1)
	{
	    $pagination = '';
	    $link = preg_replace('`%([^d])`', '%%$1', $link);
	    if ( !preg_match('`(?<!%)%d`', $link) ) $link .= '%d';
	    if ( $nb_pages > 1 ) {
 
	        // Lien précédent
	        if ( $current_page > 1 )
	            $pagination .= '<a class="prevnext" href="'.sprintf($link, $current_page-1).'#playliste" title="Page précédente">&laquo; Pr&eacute;c&eacute;dent</a>';
	        else
	            $pagination .= '<span class="prevnext disabled">&laquo; Pr&eacute;c&eacute;dent</span>';
 
	        // Lien(s) début
	        for ( $i=1 ; $i<=$firstlast ; $i++ ) {
	            $pagination .= ' ';
	            $pagination .= ($current_page==$i) ? '<span class="current">'.$i.'</span>' : '<a href="'.sprintf($link, $i).'#playliste">'.$i.'</a>';
	        }
 
	        // ... après pages début ?
	        if ( ($current_page-$around) > $firstlast+1 )
	            $pagination .= ' &hellip;';
 
	        // On boucle autour de la page courante
	        $start = ($current_page-$around)>$firstlast ? $current_page-$around : $firstlast+1;
	        $end = ($current_page+$around)<=($nb_pages-$firstlast) ? $current_page+$around : $nb_pages-$firstlast;
	        for ( $i=$start ; $i<=$end ; $i++ ) {
	            $pagination .= ' ';
	            if ( $i==$current_page )
                $pagination .= '<span class="current">'.$i.'</span>';
	            else
	                $pagination .= '<a href="'.sprintf($link, $i).'#playliste">'.$i.'</a>';
	        }
 
	        // ... avant page nb_pages ?
	        if ( ($current_page+$around) < $nb_pages-$firstlast )
	            $pagination .= ' &hellip;';
 
	        // Lien(s) fin
	        $start = $nb_pages-$firstlast+1;
	        if( $start <= $firstlast ) $start = $firstlast+1;
	        for ( $i=$start ; $i<=$nb_pages ; $i++ ) {
	            $pagination .= ' ';
	            $pagination .= ($current_page==$i) ? '<span class="current">'.$i.'</span>' : '<a href="'.sprintf($link, $i).'#playliste">'.$i.'</a>';
	        }
 
	        // Lien suivant
	        if ( $current_page < $nb_pages )
	            $pagination .= ' <a class="prevnext" href="'.sprintf($link, ($current_page+1)).'#playliste" title="Page suivante">Suivant &raquo;</a>';
        else
	            $pagination .= ' <span class="prevnext disabled">Suivant &raquo;</span>';
	    }
	    return $pagination;
	}
 
 
 
 
function paginationx($current_pagex, $nb_pagesx, $linkx='?pagevu=%d&themeziq', $aroundx=3, $firstlastx=1)
	{
	    $paginationx = '';
	    $linkx = preg_replace('`%([^d])`', '%%$1', $linkx);
	    if ( !preg_match('`(?<!%)%d`', $linkx) ) $linkx .= '%d';
	    if ( $nb_pagesx > 1 ) {
 
	        // Lien précédent
	        if ( $current_pagex > 1 )
	            $paginationx .= '<a class="prevnext" href="'.sprintf($linkx, $current_pagex-1).'#playliste" title="Page précédente">&laquo; Pr&eacute;c&eacute;dent</a>';
	        else
	            $paginationx .= '<span class="prevnext disabled">&laquo; Pr&eacute;c&eacute;dent</span>';
 
	        // Lien(s) début
	        for ( $ix=1 ; $ix<=$firstlastx; $ix++ ) {
	            $paginationx .= ' ';
	            $paginationx .= ($current_pagex==$ix) ? '<span class="current">'.$ix.'</span>' : '<a href="'.sprintf($linkx, $ix).'#playliste">'.$ix.'</a>';
	        }
 
	        // ... après pages début ?
	        if ( ($current_pagex-$aroundx) > $firstlastx+1 )
	            $paginationx .= ' &hellip;';
 
	        // On boucle autour de la page courante
	        $startx = ($current_pagex-$aroundx)>$firstlastx ? $current_pagex-$aroundx : $firstlastx+1;
	        $end = ($current_pagex+$aroundx)<=($nb_pagesx-$firstlastx) ? $current_pagex+$aroundx : $nb_pagesx-$firstlastx;
	        for ( $ix=$startx ; $ix<=$end ; $ix++ ) {
	            $paginationx .= ' ';
	            if ( $ix==$current_pagex )
                $paginationx .= '<span class="current">'.$ix.'</span>';
	            else
	                $paginationx .= '<a href="'.sprintf($linkx, $ix).'#playliste">'.$ix.'</a>';
	        }
 
	        // ... avant page nb_pages ?
	        if ( ($current_pagex+$aroundx) < $nb_pagesx-$firstlastx )
	            $paginationx .= ' &hellip;';
 
	        // Lien(s) fin
	        $startx = $nb_pagesx-$firstlastx+1;
	        if( $startx <= $firstlastx ) $startx = $firstlastx+1;
	        for ( $ix=$startx ; $ix<=$nb_pagesx ; $ix++ ) {
	            $paginationx .= ' ';
	            $paginationx .= ($current_pagex==$ix) ? '<span class="current">'.$ix.'</span>' : '<a href="'.sprintf($linkx, $ix).'#playliste">'.$ix.'</a>';
	        }
 
	        // Lien suivant
	        if ( $current_pagex < $nb_pagesx )
	            $paginationx .= ' <a class="prevnext" href="'.sprintf($linkx, ($current_pagex+1)).'#playliste" title="Page suivante">Suivant &raquo;</a>';
        else
	            $paginationx .= ' <span class="prevnext disabled">Suivant &raquo;</span>';
	    }
	    return $paginationx;
	}
 
?>