Jump to content

afaaro

Members
  • Posts

    74
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

afaaro's Achievements

Member

Member (2/5)

0

Reputation

  1. I have 11 news then i want to display like first column need only one news second column need 5 news third column need the rest of 5 news I tried this but no luck, it shows first column and second column and the rest outside column $rows = array( 'Title1', 'Title2', 'Title3', 'Title4', 'Title5', 'Title6', 'Title7', 'Title8', 'Title9', 'Title10', 'Title11', ); $total_rows = count($rows); $total_cols = $total_rows - 1;// remove first one for the first column $left_column = ceil($total_cols / 2); $right_column = $total_cols - $left_column; $i = 0; foreach ($rows as $row) { $i++; if ($i == 1) { $class = "primary_post"; echo "<div class='col-md-4 main'>"; } elseif ($i <= $left_column) { $class = "other_post"; echo "<div class='col-md-4 left'>"; } elseif ($i == $right_column) { $class = "other_post"; echo "<div class='col-md-4 right'>"; } else { $class = "other_post"; } echo "<div class='card {$class}'>$i</div>"; if ($i == 1 || $i == $left_column || $i == $right_column) { echo "</div>"; } else { echo ""; } } echo "</div>";
  2. now this is how am getting News — News Category — sub categories Diinta — Diinta category and this is how i want News — News Category —— sub categories Diinta — Diinta category
  3. function test_categories(){ $array = array(); $result = dbquery("SELECT * FROM ".CONTENT_CATEGORIES); while($data = dbarray($result)){ $array[$data['type']]['parent'][] = $data; } return $array; } function admin_list($level = FALSE){ global $class; echo "<table cellspacing='0' cellpadding='0' class='table table-responsive tbl-border center'>"; foreach(test_categories() as $category_type => $parents){ echo "<tr class='$class'><th>".$category_type."</th></tr>"; if(is_array($parents) && !empty($parents)){ foreach($parents as $parent => $children){ if(is_array($children) && !empty($children)){ foreach($children as $child){ $indent = str_repeat("--", $level); $class = bgclass(); echo "<tr class='$class'><td>".$indent="--".$child['name']."</td></tr>"; } } } } } echo "</table>"; } admin_list(); but i need to show subcategories like this and how Categories -- subcategories ---- subcategories
  4. I have tried this one but its only displaying the top category not subcategory and child category function get_subcategories($catid=0){ $result = GetList("SELECT * FROM ".DB_PREFIX."mediaCategory WHERE category_parent=$catid"); $children = array(); foreach($result as $subcat){ $current_id = $subcat['category_id']; $has_sub = GetRow("SELECT * FROM ".DB_PREFIX."mediaCategory WHERE category_parent=$current_id"); //echo $subcat['category_name'].'-'.has_subcategories($subcat['category_id'])."<br>"; if($has_sub > 0) { $children[] = get_categories($catid); } else { $children[] = $subcat['category_id']; //$children[$current_id] = array_merge($children, get_categories($current_id)); } } return $children; } //echo print_p(get_subcategories(0)); $cat = get_subcategories(1); print_p($cat); foreach($cat as $row){ if($result = GetList("SELECT p.*,c.* FROM ".DB_PREFIX."mediaPost p JOIN ".DB_PREFIX."mediaCategory c ON p.post_category=c.category_id WHERE c.category_id='".$row."' ORDER BY p.post_created DESC")){ foreach($result as $data){ echo $data['post_name']." - ".$data['category_id']."<BR>"; } } }
  5. Is there any better way?
  6. Hello every one I need help help with tihs code, it works but is there an easy way to generate articles by categories and subcategories if($result = GetList("SELECT p.*,f.*,c1.* FROM ".DB_PREFIX."mediaCategory c1 LEFT JOIN ".DB_PREFIX."mediaCategory c2 ON c2.category_id=c1.category_parent LEFT JOIN ".DB_PREFIX."mediaCategory c3 ON c3.category_id=c2.category_parent LEFT JOIN ".DB_PREFIX."mediaCategory c4 ON c4.category_id=c3.category_parent LEFT JOIN ".DB_PREFIX."mediaCategory c5 ON c5.category_id=c4.category_parent LEFT JOIN ".DB_PREFIX."mediaCategory c6 ON c6.category_id=c5.category_parent LEFT JOIN ".DB_PREFIX."mediaPost p ON c1.category_id=p.post_category WHERE (c1.category_id=1 OR c1.category_parent=1 OR c2.category_parent=1 OR c3.category_parent=1 OR c4.category_parent=1 OR c5.category_parent=1 OR c6.category_parent=1) ORDER BY p.post_created LIMIT 10")){ echo "<ul class='grid'>"; foreach ($result as $row) { echo "<li class='ID-".$row['post_id']."'><span><h3>".$row['post_name'])."</h3></span></li>"; } echo "</ul>"; }
  7. Thank you so much Ch0cu3r You are really a star
  8. Thank you Ch0cu3r It works but if i want to add date like this it doesn't work getCatid(array('post_enabled'=>'1','post_featured'=>'0', 'post_created'=>'<=UNIX_TIMESTAMP(DATE_ADD(CURDATE(),INTERVAL 1 DAY))'));
  9. I need help querying array in function its not working function getCatid($params=false){ if(is_array($params)){ foreach ($params as $key => $value) { $inputdata = $value ? "$key" : $key; } }else{ $inputdata = "0"; } if($result = GetList("SELECT * FROM ".DB_PREFIX."mediaPost WHERE $inputdata ORDER BY p.post_created DESC LIMIT 20")){ foreach ($result as $data) { echo $data['post_name']."<br>"; } } } getCatid(array("post_enabled"=>"1", "post_featured"=>"0"));
  10. Hi Psycho Thank you for your support its working now using this way SELECT * FROM ".DB_PREFIX."mediaPost WHERE post_created <= UNIX_TIMESTAMP(DATE_ADD(CURDATE(),INTERVAL -1 DAY))
  11. It updated wrong date 2038-01-19 03:14:07
  12. how can i change without losing the date data when changing to datetime
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.