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

    /***************************************************************************
                            categories.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');

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

if (!$IDCategorie)
{
	$nombre_limite=$NombreEnregistrementsLimiteAdmin;
	if (!$debut)
	{
		$debut=0;
		$DonneesCategorie=ExecRequete ("SELECT * FROM $pTable_Prefixe"."Categories WHERE NomCategorie LIKE '%$categorie%' ORDER BY NomCategorie ASC" ,BASE);

		$Record_count=mysql_num_rows($DonneesCategorie);
	}

	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;
	}

	$DonneesCategorie=ExecRequete ("SELECT * FROM $pTable_Prefixe"."Categories WHERE NomCategorie LIKE '%$categorie%' ORDER BY NomCategorie 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  a été trouvé";
			break;
		default :
 			$Record_count_text = "<I>$Record_count </I> enregistrements  ont étés trouvés";
	}
}
else
{
	$DonneesCategorie=ExecRequete ("SELECT IDDVD, Titre, $pTable_Prefixe"."Categories.IDCategorie, NomCategorie, IDZone, Appreciation, Duree, NomCategorie, $pTable_Prefixe"."DVD.IDCategorie
	FROM $pTable_Prefixe"."DVD LEFT JOIN $pTable_Prefixe"."Categories ON $pTable_Prefixe"."DVD.IDCategorie=$pTable_Prefixe"."Categories.IDCategorie
	WHERE $pTable_Prefixe"."DVD.IDCategorie=$IDCategorie
	ORDER BY Titre ASC" ,BASE);

	$requete=ExecRequete ("SELECT NomCategorie FROM $pTable_Prefixe"."Categories WHERE IDCategorie=$IDCategorie", BASE);
	$CategorieData = mysql_fetch_array ($requete);

	$DVD_count=mysql_num_rows($DonneesCategorie);

	switch ($DVD_count)
	{
		case 0 :
			$DVD_count_films = "Il n'y a aucun film";
			break;
		case 1 :
			$DVD_count_films = "Il y a <I>1</I> film";
			break;
		default :
			$DVD_count_films = "Il y a <I>$DVD_count</I> films";
	}

	if (!$numero) $numero=numero_enregistrement($IDCategorie, 4);
	$next=next_record($numero, 4);
	$prev=prev_record($numero, 4);
}

$font_begin="<font color='#FF0A3B' face='Arial, Helvetica, sans-serif' size='2'>";
$font_end="</font>";

if (!$IDCategorie)
{
	$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><center><td>";
						$form = new Formulaire ("POST", "index.php?sousPage=categories.php");
						$form->debutTable ("HORIZONTAL");
						$form->champTexte ("", "categorie", "", 30, 40);
						$form->champValider ("Recherche catégorie", "valider");
						$form->finTable();
						$form->fin();
					echo "</td></center></tr>
					</table>
					<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 ($categorie and ($valideprev==1 or $validenext==1)) $categorie=urlencode($categorie);
										if ($valideprev == 1)
										{
											echo "<a href='index.php?sousPage=categories.php&debut=$debutprecedent&Record_count=$Record_count&categorie=$categorie'><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=categories.php&debut=$debutsuivant&Record_count=$Record_count&categorie=$categorie'><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 bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;ID&nbsp;Catégorie</b></font></td>
			<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Numérotation</b></font></td>
			<td bgcolor='$color_frame' width='80%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Nom</b></font></td>
		</tr>
	<tr><td colspan=3><hr></td></tr>";


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

                    echo "		<tr>
                                        <td width='10%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowList[0] $font_end</td>
                                        <td width='10%'>$font_begin <B>$Edit_count</B> $font_end</td>
                                        <td width='80%'>$font_begin <a href='index.php?IDCategorie=$rowList[0]&sousPage=categories.php'>"; $rowList[1]=nbsp($rowList[1]); echo "$rowList[1]</a>$font_end</td>";
                        echo "</tr>";
            }
			if ($Record_count!=0) echo "</table>";
            echo "<hr>";
		}
}
else
{
echo
"<TABLE height='100%' cellSpacing=0 cellPadding=0 width='100%' border=0>
        <TBODY>
                <TR bgColor=$color_back>
                        <TD vAlign=top>
                                <TABLE cellSpacing=0 cellPadding=0 width='100%' border=0 onKeyPress=changeUrlKeyBoard()>
                                        <TBODY>
                                                <TR>
                                                        <TD vAlign=top align=left>
                                                        	<H1>Catégorie - $CategorieData[0]</H1>
                                                        </TD>
														<TD align=right>"; if ($prev!=-1) echo "<A NAME=prev href=index.php?sousPage=categories.php&IDCategorie=$prev><IMG border=0 src='images/prev.gif'></A>"; else echo "<A NAME=prev href=''></A><IMG border=0 src='images/prevdis.gif'>"; if ($next!=-1) echo "<A NAME=next  href=index.php?sousPage=categories.php&IDCategorie=$next><IMG border=0 src='images/next.gif'></A>"; else echo "<A NAME=next href=''></A><IMG border=0 src='images/nextdis.gif'>";echo "</TD>
                                                </TR>
                                          </TBODY>
                                  </TABLE>
								<TABLE cellSpacing=0 cellPadding=0 width='100%' border=0>
										<TBODY>
                                                <TR>
                                                        <TD vAlign=top>
                                                                <TABLE width='100%' cellSpacing=0 cellPadding=0 border=0>
                                                                        <TBODY>
                                                                                <TR>
                                                                                        <TD vAlign=top><BR><B>$DVD_count_films de cette catégorie (dans cette base de données) </B></TD>
																				</TR>";
																				if ($DVD_count!=0)
																				{
																				echo "
																				<TR>
																				</TR>
																				<TR>
                                                                                        <TD vAlign=top>
                                                                                                <BR>
																								<table width='100%' border=0 cellspacing=1 cellpadding=1>
                    																				<tr>
                    																					<td bgcolor='$color_frame' width='5%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;ID&nbsp;DVD</b></font></td>
                    																					<td bgcolor='$color_frame' width='45%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Titre&nbsp;du&nbsp;film</b></font></td>
                    																					<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Durée</b></font></td>
                    																					<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Catégorie</b></font></td>
                    																					<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Zone(s)</b></font></td>
                    																					<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Appréciation</b></font></td>";
                    																					if ($DVD_count<30) echo "<td bgcolor='$color_frame' width='10%'><b><font face='Arial, Helvetica, sans-serif' size='2' color='$color_menu'>&nbsp;Affiche</b></font></td>";
                    																				echo "</tr>
                    																				<tr><td colspan=7><hr></td></tr>";
                                                                                                while ($rowDVD=mysql_fetch_array($DonneesCategorie))
                                                                                                {
																										echo "		<tr>
																															<td width='5%'><font color='#000000' face='Arial, Helvetica, sans-serif' size='2'>$rowDVD[0] $font_end</td>
																															<td width='45%'>$font_begin <a href='index.php?IDDVD=$rowDVD[0]&sousPage=ficheDVD.php'>"; $rowDVD[1]=nbsp($rowDVD[1]); echo "$rowDVD[1]</a>$font_end</td>
																															<td width='10%'>$font_begin $rowDVD[6] $font_end</td>
																															<td width='10%'>$font_begin"; $rowDVD[7]=nbsp($rowDVD[7]); echo "$rowDVD[7] $font_end</td>";
																															if ($DVD_count<30) $zonestexte = zones_texte($rowDVD[4], 'TRUE');
																															else $zonestexte = zones_texte($rowDVD[4]);
																															echo "<td width='10%'>$font_begin $zonestexte $font_end</td>";
																															echo "<td width='10%'>$font_begin $rowDVD[5] $font_end</td>";
																															if ($DVD_count<30)
																															{
																																if(file_exists($pCoversPath.$rowDVD[0].'.jpg')) echo "<td width='10%' valigh='top'><IMG height=85 src=$pCoversPath$rowDVD[0].jpg></td>";
																																else echo "<td width='10%' valign='top'><IMG height=85 src=images/NoImage.gif></td>";
																															}
																										echo "</tr>";
                                                                                                }
                                                                                        if ($DVD_count!=0) echo "</table>";
																						echo "
                                                                                        </TD>
                                                                                </TR>";
																				}
																		echo "
                                                                        </TBODY>
                                                                </TABLE>
                                                        </TD>
                                                </TR>
                                        </TBODY>
                                </TABLE>
                        </TD>
                </TR>
        </TBODY>
</TABLE>";
}

?>
Return current item: PhpMyDVDs