Advertisement
Guest User

Untitled

a guest
Aug 20th, 2013
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. $sql = $azdb->get_row("SELECT * FROM ".$table_prefix."_content WHERE ID='".$_GET['ID']."'");
  2.  
  3. if($sql):
  4.  
  5. echo '<h2>'.$sql->content_title.'</h2>';
  6.  
  7. echo date('d m Y',strtotime($sql->content_modified));
  8.  
  9. echo '<br />';
  10.  
  11. echo $sql->content;
  12.  
  13. endif;
  14.  
  15.  
  16.  
  17. $sql = $azdb->get_results("SELECT * FROM ".$table_prefix."_content WHERE content_parent='".$_GET['ID']."'");
  18.  
  19. if($sql): foreach($sql as $sql):
  20.  
  21. echo '<div class="comments">';
  22.  
  23. echo '<h2>Main '.$sql->content_title.'</h2>';
  24.  
  25. echo date('d m Y',strtotime($sql->content_modified));
  26.  
  27. echo '<br />';
  28.  
  29. echo $sql->content;
  30.  
  31. echo '<br />';
  32.  
  33.  
  34.  
  35.  
  36. $sql1 = $azdb->get_results("SELECT * FROM ".$table_prefix."_content WHERE content_parent='".$sql->ID."'");
  37.  
  38. if($sql1): foreach($sql1 as $sql1):
  39.  
  40. echo '<div class="comments">';
  41.  
  42. echo '<h2>'.$sql1->ID.' - '.$sql1->content_title.'</h2>';
  43.  
  44. echo date('d m Y',strtotime($sql1->content_modified));
  45.  
  46. echo '<br />';
  47.  
  48. echo $sql1->content;
  49.  
  50. $sql2 = $azdb->get_results("SELECT * FROM ".$table_prefix."_content WHERE content_parent='".$sql1->ID."' ");
  51.  
  52. if($sql2): foreach($sql2 as $sql2):
  53.  
  54. echo '<div class="comments">';
  55.  
  56. echo '<h2>'.$sql2->content_title.'</h2>';
  57.  
  58. echo date('d m Y',strtotime($sql2->content_modified));
  59.  
  60. echo '<br />';
  61.  
  62. echo $sql2->content;
  63.  
  64. echo '</div>';
  65.  
  66. endforeach; endif;
  67.  
  68. echo '</div>';
  69.  
  70. endforeach; endif;
  71.  
  72. echo '</div>';
  73.  
  74. endforeach; endif;
  75.  
  76. $id = isset($_GET['id']) ? $_GET['id'] : 0;
  77. $root_sql = $azdb->get_results("SELECT * FROM categories WHERE cat_parent = " . $id);
  78.  
  79. recursive_categories($root_sql);
  80.  
  81. function recursive_categories($results)
  82. {
  83. if(count($results))
  84. {
  85. echo "<ul>";
  86. foreach($results as $res)
  87. {
  88. echo "<li>" . $res->category;
  89. //Rest of what ever you want to do with each row
  90.  
  91. //Check this category for children
  92. $rows = $azdb->get_results("SELECT * FROM categories WHERE cat_parent = " . $res->id);
  93.  
  94. recursive_categories($rows);
  95.  
  96. //has to be after the inner loops
  97. echo "</li>";
  98. }
  99. echo "</ul>";
  100. }
  101. }
  102.  
  103. 1 - main
  104. 1.1 - comment 1
  105. 1.2 - comment 2
  106. 1.2.1 - nested comment for comment 2
  107. 1.2.1.1 - nested comment for comment 2, nested comment 1
  108. 1.2.2
  109. 1.2.3
  110. 1.2.2.1
  111. 1.1.1 - (this comment you could order by your sql call to be 3rd from the top, etc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement