| 12
 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
 
 | <?php
require('connect.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<link href="css/style.css" rel="stylesheet"/>
<head>
   <script src="js/jquery.js"></script>
   <script>
        $(document).ready(function() {
          $('.link').click(function(){
            $.ajax({
               type: 'GET',
               url: 'categories.php',
               data: 'last_id='+$(this).attr('id'),
 
               success: function(data){
                 $('#sousRubriques').html(data);
               };
            });
            }); 
        });
   </script>
</head>
<body>
    <div id="box">
    <div id="rubriques">
      <?php
      $req = $bdd->prepare('select * from rubrique');
      $req->execute();
      echo '<table class="categories">';
      while($data = $req->FETCH(PDO::FETCH_OBJ)):?>
            <tr> <td><img height=29; width=32; src="images/categories/<?php echo $data->id.'.png'?>" /></td> <td><p class="link" id="<?php echo $data->id;?>"><?php echo $data->nom; ?> </p></td> </tr>
      <?php endwhile;
      echo '</table>';
      $req->closeCursor();?>
    </div>
    <div id="sousRubriques">
      <?php
 
        if(!empty($_GET['last_id'])){
            $last_id = striptags($_GET['last_id']);
            $req = $bdd->prepare('SELECT * FROM sous_rubrique WHERE "id_rub" like :last_id');
            $req->execute(array(':last_id'=>$last_id));
             echo '<ul>';
             while($data = $req->FETCH(PDO::FETCH_OBJ)):?>
               <li><?php echo $data->nom;?></li>
             <?php endwhile;
             echo '</ul>';
             $req->closeCursor();
        }
        else{
            header('Location: categories.php');
        }
 
      ?>
    </div>
    <div style="clear:both;"></div>
    </div>
</body>
</html> |