Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once(__DIR__."/../includes/config.php");
- require_once(__DIR__."/../includes/functions.php");
- startSession();
- define('DSN','mysql:host=localhost;dbname=solvedesktop');
- define('USERNAME' , 'root');
- define('PASSWORD' , '');
- try {
- $DB = new PDO(DSN, USERNAME, PASSWORD);
- } catch(PDOException $e) {
- echo $e->getMessage();
- }
- try {
- if(isset($_SESSION["id"])){
- $sql = "SELECT * FROM drop_down WHERE published = 1 AND loggedin = 1";
- $result = $DB->query($sql);
- $row_count = $result->rowCount();
- if($row_count){
- $rows = $result->fetchAll(PDO::FETCH_ASSOC);
- }
- } else {
- $sql = "SELECT * FROM drop_down WHERE published = 1 AND loggedin = 0";
- $result = $DB->query($sql);
- $row_count = $result->rowCount();
- if($row_count){
- $rows = $result->fetchAll(PDO::FETCH_ASSOC);
- }
- }
- catch(PDOException $e) {
- echo $e->getMessage();
- }
- }
- <?php
- $items = $rows;
- $id = '';
- echo "<ul class ='multidrop'>";
- foreach($items as $item){
- if($item['parent_id'] == 0){
- echo "<li><a href=../home/view.php?id=".$item['id'].">".$item['title']."</a>";
- $id = $item['id'];
- sub($items, $id);
- echo "</li>";
- }
- }
- echo "</ul>";
- function sub($items, $id){
- echo "<ul>";
- foreach($items as $item){
- if($item['parent_id'] == $id){
- echo "<li><a href=../home/view.php?id=".$item['id'].">".$item['title']."</a>";
- sub($items, $item['id']);
- echo "</li>";
- }
- }
- echo "</ul>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement