Advertisement:

Author Topic: function to calculate the ad type in the user panel?  (Read 1320 times)

monah

  • Full Member
  • ***
  • Posts: 223
function to calculate the ad type in the user panel?
« on: March 15, 2015, 12:20:42 am »
Tell me how to create a function to calculate the ad type in the user panel?
But for these types of
a href="http://vvvvvvvvv/user/items">
    <a href="http://vvvvvvv/user/items?itemType=active">
    <a href="http://vvvvv/user/items?itemType=blocked">
    <a href="http://vvvvvv/user/items?itemType=premium">
    <a href="http://vvvvvuser/items?itemType=pending_validate">
    <a href="http://vvvvvvvv/user/items?itemType=expired">

monah

  • Full Member
  • ***
  • Posts: 223
Re: function to calculate the ad type in the user panel?
« Reply #1 on: March 16, 2015, 11:57:09 am »
can anyone help here it is ))) Tell me how to calculate the number of expired ads?
Code: [Select]
<a href="http://test.com/user/items?itemType=all">Все (<?php $conn getConnection();
$user_total_items $conn->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item WHERE fk_i_user_id = '%d'"DB_TABLE_PREFIXosc_logged_user_id());
echo $user_total_items ['count'?>
)</a>
    <a href="http://test.com/user/items?itemType=active">Активные (<?php $conn1 getConnection();
    
$result1 $conn1->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 1"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result1['count'];?>
) </a>
    <a href="http://test.com/user/items?itemType=blocked">Блокированные (<?php $conn2 getConnection();
    
$result2 $conn2->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_enabled = 0"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result2['count'];?>
)</a>
<a href="http://test.com/user/items?itemType=premium">VIP (<?php $conn3 getConnection();
    
$result3 $conn3->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_premium = 1"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result3['count'];?>
)</a>
    <a href="http://test.com/user/items?itemType=pending_validate">Неактивные (<?php $conn4 getConnection();
    
$result4 $conn4->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 0"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result4['count'];?>
)</a>
    <a href="http://test.com/user/items?itemType=expired">expired (?????????????);
    echo $result5['count'];?>)</a>

prutix

  • Newbie
  • *
  • Posts: 19
Re: function to calculate the ad type in the user panel?
« Reply #2 on: May 17, 2015, 01:15:59 am »
can anyone help here it is ))) Tell me how to calculate the number of expired ads?
Code: [Select]
<a href="http://test.com/user/items?itemType=all">Все (<?php $conn getConnection();
$user_total_items $conn->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item WHERE fk_i_user_id = '%d'"DB_TABLE_PREFIXosc_logged_user_id());
echo $user_total_items ['count'?>
)</a>
    <a href="http://test.com/user/items?itemType=active">Активные (<?php $conn1 getConnection();
    
$result1 $conn1->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 1"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result1['count'];?>
) </a>
    <a href="http://test.com/user/items?itemType=blocked">Блокированные (<?php $conn2 getConnection();
    
$result2 $conn2->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_enabled = 0"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result2['count'];?>
)</a>
<a href="http://test.com/user/items?itemType=premium">VIP (<?php $conn3 getConnection();
    
$result3 $conn3->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_premium = 1"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result3['count'];?>
)</a>
    <a href="http://test.com/user/items?itemType=pending_validate">Неактивные (<?php $conn4 getConnection();
    
$result4 $conn4->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 0"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result4['count'];?>
)</a>
    <a href="http://test.com/user/items?itemType=expired">expired (?????????????);
    echo $result5['count'];?>)</a>

Try this:

Insert into functions.php this code
Code: [Select]
function user_ads_expired(){
  $id_user = osc_logged_user_id();
  $curent_date = date('Y-m-d H:i:s');
            $dao = new DAO();
               $dao->dao->select('count(pk_i_id) as total');
               $dao->dao->from(DB_TABLE_PREFIX.'t_item');
               $dao->dao->where('fk_i_user_id', $id_user );
      $dao->dao->where('dt_expiration < ', $curent_date);
              $result = $dao->dao->get();
              $detail = $result->row();
        $items  = $result->row();
              echo $items['total'];
   
 }

and
insert into user-items, ths code

Code: [Select]
Expired Items <?php user_ads_expired(); ?>

monah

  • Full Member
  • ***
  • Posts: 223
Re: function to calculate the ad type in the user panel?
« Reply #3 on: May 17, 2015, 11:54:00 am »
thanks)))))))))

monah

  • Full Member
  • ***
  • Posts: 223
Re: function to calculate the ad type in the user panel?
« Reply #4 on: May 17, 2015, 11:35:19 pm »
  <a href="http://wwwwwwww.by/user/items?itemType=active">Активные (<?php $conn1 = getConnection();
    $result1 = $conn1->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 1 AND i.b_enabled = 1", DB_TABLE_PREFIX, osc_logged_user_id());
    echo $result1['count'];?>) </a>
like here to add conditions that have not yet expired ads?
« Last Edit: May 20, 2015, 01:52:48 am by monah »

monah

  • Full Member
  • ***
  • Posts: 223
Re: function to calculate the ad type in the user panel?
« Reply #5 on: July 21, 2015, 10:27:27 pm »
Code: [Select]
<a href="http://test.by/user/items?itemType=active">Активные (<?php $conn1 getConnection();
    
$result1 $conn1->osc_dbFetchResult("SELECT COUNT(*) as count FROM %st_item i WHERE i.fk_i_user_id = '%d'
     AND i.b_active = 1 AND i.b_enabled = 1 AND i.dt_expiration > NOW()"
DB_TABLE_PREFIXosc_logged_user_id());
    echo 
$result1['count'];?>
) </a>
here is the solution