Php forgaine key

fdawch Messages postés 51 Date d'inscription   Statut Membre Dernière intervention   -  
jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   -
Bpnjour les amis
SVP j'ai une pages qui affiche les albums et leurs photos, j'ai deux table album et galeriephpto avec une clé étrangère, j'ai récupéré les informations mais je veux que chaque titre album affiche ses images au dessous.
vous trouverez le code concerné
Merci

<?php
@session_start();
$cnx = @mysql_connect( "localhost", "root", "" );
$db= @mysql_select_db( "cneree" );


$sql1 = "SELECT DISTINCT titreA FROM `album`,galeriephoto where album.id_album = galeriephoto.album";
$requete1 = @mysql_query( $sql1, $cnx ) or die( "ERREUR MYSQL numéro: ".mysql_errno()."<br>Type de cette erreur: ".mysql_error()."<br>\n" );

$sql2 = "SELECT image,album.titreA FROM galeriephoto, album where galeriephoto.album = album.id_album ";
$requete2 = @mysql_query( $sql2, $cnx ) or die( "ERREUR MYSQL numéro: ".mysql_errno()."<br>Type de cette erreur: ".mysql_error()."<br>\n" );

?>

<!DOCTYPE html>
<!--[if IE 8 ]><html class="ie" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html><!--<![endif]-->
<head>
    <!-- Basic Page Needs -->
    <meta charset="utf-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->


    <meta name="author" content="themesflat.com">

    <!-- Mobile Specific Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <!-- Bootstrap  -->
    <link rel="stylesheet" type="text/css" href="stylesheets/bootstrap.css" >

    <!-- Theme Style -->
    <link rel="stylesheet" type="text/css" href="stylesheets/style.css">

    <!-- Responsive -->
    <link rel="stylesheet" type="text/css" href="stylesheets/responsive.css">
    
    <!-- Colors -->
    <link rel="stylesheet" type="text/css" href="stylesheets/colors/color1.css" id="colors">
    
    <!-- Animation Style -->
    <link rel="stylesheet" type="text/css" href="stylesheets/animate.css">

    <!-- Favicon and touch icons  -->
    <link href="icon/apple-touch-icon-48-precomposed.png" rel="apple-touch-icon-precomposed" sizes="48x48">
    <link href="icon/apple-touch-icon-32-precomposed.png" rel="apple-touch-icon-precomposed">
    <link href="#" rel="shortcut icon">

    <!--[if lt IE 9]>
        <script src="javascript/html5shiv.js"></script>
        <script src="javascript/respond.min.js"></script>
    <![endif]-->

	<link rel="shortcut icon" href="images/New_Logo_Cneree.png" />
	<style type="text/css">
		.owl-prev {
  background: url('left.png') left center no-repeat;
  height: 54px;
  position: absolute;
  top: 50%;
  width: 27px;
  z-index: 1000;
  left: 2%;
  cursor: pointer;
  color: transparent;
  margin-top: -27px;
}

.owl-next {
  background: url('right.png') right center no-repeat;
  height: 54px;
  position: absolute;
  top: 50%;
  width: 27px;
  z-index: 1000;
  right: 2%;
  cursor: pointer;
  color: transparent;
  margin-top: -27px;
}

.owl-prev:hover,
.owl-next:hover {
  opacity: 0.5;
}


/* Owl Carousel */



	</style>
</head>

<body class="header-sticky">

    <div class="boxed">

       

        <!-- menu -->
        <?php include("menu2.php");?>

        <div class="page-title full-color" >
            <div class="container">
                <div class="row">
                    <div class="col-md-12">                    
                        <div class="page-title-heading">
                            <h2 class="title">Galeries Photos</h2>
                        </div>          
                    </div>
                </div> 
            </div>                     
        </div>


        
<div class="container">
    <?php
while( $result1 = mysql_fetch_array( $requete1 ) ) { ?>
     <br><h1 style="font-size: 20px"><?php echo($result1["titreA"]."\n" ); ?></h1><br>
     <?php } ?>
<div class="owl-carousel">
<?php
while( $result2 = mysql_fetch_array( $requete2 ) )
{ echo '<img src="gestion/upload/GaleriePhoto/'.$result2["image"].'">';  } 
?>
</div></div><br>

		



<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.0.0-beta.3/owl.carousel.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.js"></script>

<script type="text/javascript">
	$('.owl-carousel').owlCarousel({
  autoplay: true,
  loop: true,
  margin: 25,
  responsiveClass: true,
  nav: true,
  loop: true,
  responsive: {
    0: {
      items: 1
    },
    568: {
      items: 2
    },
    600: {
      items: 3
    },
    1000: {
      items: 4
    }
  }
})


</script>

        <!--footer-->
        <?php include("footer.php"); ?>

        
        <!-- Fixe Menu -->
        <script type="text/javascript" src="javascript/jquery.min.js"></script>
        <script type="text/javascript" src="javascript/jquery.cookie.js"></script> 
        <script type="text/javascript" src="javascript/main.js"></script>
        

    </div>
</body>
</html>
A voir également:

1 réponse

jordane45 Messages postés 38486 Date d'inscription   Statut Modérateur Dernière intervention   4 752
 
Comme déjà dit

L'extension mysql est OBSOLETE.
Il faut passer à PDO ou MYSQLI
Merci de lire ceci : https://www.commentcamarche.net/faq/43261-php-l-extension-mysql-est-obsolete#top



Ensuite... Recherche ce qu'est une jointure en sql...




0