What I'm doing wrong?

Discussion in 'PHP' started by Divvy, Dec 15, 2011.

  1. #1
    Hello guys,

    I have an website listing movies and series.
    But I having problems showing the content in my "last added" block.

    Look:
    http://screensnapr.com/e/Zm4ssA.jpg

    Only movies is showing, but not series...
    Is the php file code If you wish to take a look:
    http://paste2.org/p/1824759

    categorie ID is correct: 7

    the movies block sometimes have this issue too... the code is almost the same as above, maybe is the same problem...

    Can someone help me? :)
    Thank you!
     
    Divvy, Dec 15, 2011 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Hi there,

    Its hard to tell that just from a piece of code, but first look says that you only 'load' the movies part. But then again, to less lines of code.

    You should offer more details to give us more to work with!
     
    EricBruggema, Dec 15, 2011 IP
  3. codecre8r

    codecre8r Well-Known Member

    Messages:
    148
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Your SQL query is only pulling 3 records (line 38). Try changing your sql to this:

    $sql = $db->query( "SELECT id, title, date, alt_name, category,xfields,autor FROM " . PREFIX . "_post WHERE category like '%7%' ORDER BY date DESC LIMIT 6" );
    Code (markup):
     
    codecre8r, Dec 15, 2011 IP
  4. Divvy

    Divvy Well-Known Member

    Messages:
    785
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #4
    Thank you guys for your reply!

    codecre8r, I only want to pull 3 results for each category :)

    EricBruggema,sure, that is not a problem. What do you need to know so you can help me? :)
    Let me explain better:

    My website have 5 categories in the index.
    I want to show last 3 posts in each category...
    For each category that I want to show their posts, I have a file called newhome_x.php

    In my templates/dirvideo/main.tpl file, I have this code:
    <div id="page_content" class="clearfix">
    {info} {newhome_final} {content}
    </div>
    Code (markup):
    In my templates/dirvideo/newhome.tpl file, I have this code:
    <li style="margin-right: 45px;" onclick="window.location='{link}'">
    <a title='{home_title}' href="{link}"><img src="[xfvalue_poster]" alt='{home_title}' /></a>
    <h3 style="overflow:hidden"><a title='{home_title}' href="{link}">{home_title}</a></h3>
    </li>
    Code (markup):
    in my index.php I have this code:
    require_once ENGINE_DIR . '/modules/newhome.php';
    require_once ENGINE_DIR . '/modules/newhome_b.php';
    require_once ENGINE_DIR . '/modules/newhome_c.php';
    require_once ENGINE_DIR . '/modules/newhome_d.php';
    require_once ENGINE_DIR . '/modules/newhome_e.php';
    
    if (clean_url ( $_SERVER['HTTP_HOST'] ) != clean_url ( $config['http_home_url'] )) {
    
    	$replace_url = array ();
    	$replace_url[0] = clean_url ( $config['http_home_url'] );
    	$replace_url[1] = clean_url ( $_SERVER['HTTP_HOST'] );
    
    } else
    	$replace_url = false;
    
    if (!$is_logged && !in_array($_GET['do'], array('register', 'lostpassword'))) { include 'index.html'; die; }
    $tpl->load_template ( 'main.tpl' );
    $tpl->set ( '{lastusers}', $lastusers);
    $tpl->set('{forumStyle}', require_once ROOT_DIR . '/engine/bullet_energy/modules/load_style.php');
    require_once ENGINE_DIR . '/modules/3news.php';$source = '<div class="index_top1" style="width: 100%; padding-top: 10px; padding-bottom: 10px; " >						
    <span style="font-size: 24px; margin-left: 10px;"><img border="0" src="templates/dirvideo/images/movies.gif">
    </span>
    <ul class="clearfix">
    {newhome}
    </ul>
    </div>
    <div class="index_top2" style="width: 100%; padding-top: 10px; padding-bottom: 10px; " >
    <span style="font-size: 24px; margin-left: 10px;"><img border="0" src="templates/dirvideo/images/serie.gif">
    </span>
    <ul class="clearfix">
    {newhome_b}
    </ul>
    </div>
    <div class="index_top3" style="width: 100%; padding-top: 10px; padding-bottom: 10px; " >
    <span style="font-size: 24px; margin-left: 10px;"><img border="0" src="templates/dirvideo/images/music.gif">
    </span>
    <ul class="clearfix">
    {newhome_c}
    </ul>
    </div>
    <div class="index_top6" style="width: 100%; padding-top: 10px; padding-bottom: 10px; " >
    <span style="font-size: 24px; margin-left: 10px;"><img border="0" src="templates/dirvideo/images/jogo.gif">
    </span>
    <ul class="clearfix">
    {newhome_e}
    </ul>
    </div>
    <div class="index_top4" style="width: 100%; padding-top: 10px; padding-bottom: 10px; " >
    <span style="font-size: 24px; margin-left: 10px;"><img border="0" src="templates/dirvideo/images/programas.gif">
    </span>
    <ul class="clearfix">
    {newhome_d}
    </ul>
    </div>';
    if (!isset($_REQUEST["catalog"]) && !isset($_REQUEST["newsid"]) && !isset($_REQUEST["do"]) && !isset($_REQUEST["page"]) && !isset($_REQUEST["category"]) && !isset($_REQUEST["cat"]) && !isset($_REQUEST["action"]) && !isset($_REQUEST["id"]) && !isset($_REQUEST["name"]) && !isset($_REQUEST["news_name"]) && !isset($_REQUEST["seourl"]) && !isset($_REQUEST["findpost"]) && !isset($_REQUEST["subaction"])) {	$tpl->set ( '{newhome_final}', $source);} else {	$tpl->set ( '{newhome_final}', "");}
    
    $tpl->set ( '{referer}', $referer_block );
    $tpl->set ( '{calendar}', $tpl->result['calendar'] );
    $tpl->set ( '{top_news}', $top_news );
    $tpl->set ( '{last_news}', $last_news );
    $tpl->set ( '{rand_news}', $rand_news );
    $tpl->set ( '{archives}', $tpl->result['archive'] );
    $tpl->set ( '{tags}', $tpl->result['tags_cloud'] );
    $tpl->set ( '{vote}', $tpl->result['vote'] );
    $tpl->set ( '{topnews}', $topnews );
    $tpl->set ( '{login}', $tpl->result['login_panel'] );
    $tpl->set ( '{info}',  $tpl->result['info'] );
    $tpl->set ( '{speedbar}', $tpl->result['speedbar'] );
    $tpl->set ( '{catlist}', $catlist );
    $tpl->set ( '{moviepopular}', $tpl->result['moviepopular'] );$tpl->set ( '{newhome}', $tpl->result['newhome'] );$tpl->set ( '{newhome_b}', $tpl->result['newhome_b'] );$tpl->set ( '{newhome_c}', $tpl->result['newhome_c'] );$tpl->set ( '{newhome_d}', $tpl->result['newhome_d'] );$tpl->set ( '{newhome_e}', $tpl->result['newhome_e'] );
    Code (markup):
    In my engine/modules folder I have the files:
    newhome.php
    newhome_b.php
    newhome_c.php
    newhome_d.php
    newhome_e.php

    This is the code of engine/modules/newhome_c.php file:
    http://paste2.org/p/1824759

    I think that is everything here :)
    Can you help me?

    P.S. Sometimes when I add new posts, appears in the block, and when I post other, disappear all from that category block...
     
    Divvy, Dec 15, 2011 IP