Location: PHPKode > projects > PhpMyDVDs > phpmydvds/listingDVD.php
<?php

    /***************************************************************************
                            listingDVD.php  -  description
                                -------------------

        copyright          : (C) 2002 by Cédric Rochat
        email                : hide@address.com
    ***************************************************************************/
    /***************************************************************************
    *
    *   This program is free software; you can redistribute it and/or modify
    *   it under the terms of the GNU General Public License as published by
    *   the Free Software Foundation; either version 2 of the License, or
    *   (at your option) any later version.
    *
    ***************************************************************************/
    require ("util.php");

    function listing($dvd, $Record_count=0, $debut=0)
    {
        require ("config.php");

		$connexion = Connexion (NOM, PASSE, BASE,SERVEUR);

		$nombre_limite=$NombreEnregistrementsLimiteAdmin;

		if (!$debut)
		{
			$debut=0;
        	if($dvd=="")
            	$listing_total=ExecRequete ("SELECT IDDVD, Titre, Duree, IDZone, Appreciation, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie
				FROM $pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
				ORDER BY Titre ASC",BASE);
        	else
            	$listing_total=ExecRequete ("SELECT IDDVD, Titre, Duree, IDZone, Appreciation, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie
				FROM $pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
				WHERE Titre LIKE '%$dvd%' ORDER
				BY Titre ASC" ,BASE);

			$Record_count=mysql_num_rows($listing_total);
		}

		if ($debut >= $nombre_limite)
		{
			$valideprev=1;
			$debutprecedent=$debut-$nombre_limite;
		}
		else $valideprev=0;

		if (($debut+$nombre_limite) > $Record_count) $validenext=0;
		else
		{
			$validenext=1;
			$debutsuivant=$debut+$nombre_limite;
		}

        if($dvd=="")
            $listing=ExecRequete ("SELECT IDDVD, Titre, Duree, IDZone, Appreciation, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie
			FROM $pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
			ORDER BY Titre ASC LIMIT $debut, $nombre_limite",BASE);
        else
            $listing=ExecRequete ("SELECT IDDVD, Titre, Duree, IDZone, Appreciation, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie
			FROM $pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
			WHERE Titre LIKE '%$dvd%' ORDER
			BY Titre ASC LIMIT $debut, $nombre_limite" ,BASE);


	   switch ($Record_count)
		{
			case 0 :
 				$Record_count_text = "Aucun enregistrement n'a été trouvé";
				break;
			case 1 :
 				$Record_count_text = "<I>$Record_count </I> enregistrement  à été trouvé";
				break;
			default :
 				$Record_count_text = "<I>$Record_count </I> enregistrements  ont étés trouvés";
		}

        echo "  <table width='100%' border=0 cellspacing=1 cellpadding=1>
					<tr><td align=center>";
						$form = new Formulaire ("POST", "index.php?sousPage=listingDVD.php");
						$form->debutTable ("HORIZONTAL");
						$form->champTexte ("", "dvd", "", 30, 40);
						$form->champValider ("Recherche titre", "valider", 30, 40);
						$form->finTable();
						$form->fin();
					echo "</td></tr>
					</table>";

					$pages_tot=$Record_count/$nombre_limite;
					if ($pages_tot > floor($pages_tot)) $pages_tot=floor($pages_tot)+1;
					$page_actuelle=floor($debut/$nombre_limite)+1;

					echo "
					<table width='100%' border=0 cellspacing=1 cellpadding=1>
					<tr>
						<td>
							<br>
							<b>$Record_count_text</b>
						</td>
						<td align='right'>
							<table border='0' cellspacing='0' cellpadding='0'>
								<tr>
									<td align='right'><b>"; if ($pages_tot > 1) echo "$page_actuelle/$pages_tot"; echo "</b></td>
									<td align='right'>";
										if ($dvd and ($valideprev==1 or $validenext==1)) $dvd=urlencode($dvd);
										if ($valideprev == 1)
										{
											echo "<a href='index.php?sousPage=listingDVD.php&debut=$debutprecedent&Record_count=$Record_count&dvd=$dvd'><img border='0' src='images/prev.gif'></a>";
										}
										else
										{
											if ($pages_tot > 1) echo "<img border='0' src='images/prevdis.gif'>";
										}

										if ($validenext == 1)
										{
											echo "<a href='index.php?sousPage=listingDVD.php&debut=$debutsuivant&Record_count=$Record_count&dvd=$dvd'><img border='0' src='images/next.gif'></a>";
										}
										else
										{
											if ($pages_tot > 1) echo "<img border='0' src='images/nextdis.gif'>";
										}
									echo "</td>
								</tr>
							</table>
						</td>
					</tr>
					</table>";

					if ($Record_count!=0)
					{
					echo "
					<table width='100%' border=0 cellspacing=1 cellpadding=1>
                    <tr>
                    <td width='5%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;ID&nbsp;DVD</font></b></td>
                    <td width='10%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Numérotation</font></b></td>
                    <td width='45%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Titre&nbsp;du&nbsp;film</font></b></td>
                    <td width='10%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Durée</font></b></td>
                    <td width='10%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Catégorie</font></b></td>
                    <td width='10%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Zone(s)</font></b></td>
                    <td width='10%' bgcolor='$color_frame'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Appréciation</font></b></td>
                    </tr>
                    <tr><td colspan=7><hr></td></tr>";


        	$font_begin="<font color='#FF0A3B' face='Arial, Helvetica, sans-serif' size='2'>";
        	$font_end="</font>";
        	$DVD_count=$debut;
            while ($rowList = mysql_fetch_array ($listing))
            {
                    $href_begin ="";
                    $href_end ="";
                    $DVD_count++;

                    echo "		<tr>
                                        <td width='5%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowList[0] $font_end</td>
                                        <td width='10%'>$font_begin <B>$DVD_count</B> $font_end</td>
                                        <td width='45%'>$font_begin <a href='index.php?IDDVD=$rowList[0]&sousPage=ficheDVD.php'>"; $rowList[1]=nbsp($rowList[1]); echo "$rowList[1]</a>$font_end</td>
                                        <td width='10%'>$font_begin $rowList[2] $font_end</td>
                                        <td width='10%'>$font_begin <a href='index.php?IDCategorie=$rowList[6]&sousPage=categories.php'>"; $rowList[5]=nbsp($rowList[5]); echo "$rowList[5]</a>$font_end</td>";
                    $zonestexte = zones_texte($rowList[3]);
                    echo "<td width='10%'>$font_begin $zonestexte $font_end</td>";
                    echo "<td width='10%'>$font_begin $rowList[4] $font_end</td>";
                    echo "</tr>";
            }
            if ($Record_count!=0) echo "</table>";
			echo "<hr>";
      	}
      }


    require ("util.php");
	if ($dvd) $dvd=urldecode($dvd);
    listing($dvd, $Record_count, $debut);

?>
Return current item: PhpMyDVDs