PDA

View Full Version : Problem calling $count[threads] variable


Grunt
05-06-2003, 01:57 AM
im working on a little hack, however im having a problem calling a variable in a template. here is the call:

$count[threads] new thread$pluralthread

If a new thread(s) have been made, the # will show no problem - the plural variable is working fine also. However, if no threads have been made, instead of showing 'No' like i think i specified below, nothing is showing up. Heres the code where they are defined:

$newthreads = '';
if ( $activenewthread )
{
if ( $dothreads = $DB_site->query_first("
SELECT COUNT(*) AS total
FROM thread
WHERE $iforumperms AND dateline>$bbuserinfo[lastvisit]
") and !empty( $dothreads['total'] ) )
{
$count['threads'] = number_format( $dothreads['total'] );
$count['threads'] = iif ( $count['threads']!=0 , $count['threads'] , 'No' );
$pluralthread = iif ( $count['threads']!=1 , 's' , '' );
}
}

Xenon
05-06-2003, 04:02 PM
i think you would get type mismatches here try this code:

$newthreads = '';
if ( $activenewthread )
{
if ( $dothreads = $DB_site->query_first("
SELECT COUNT(*) AS total
FROM thread
WHERE $iforumperms AND dateline>$bbuserinfo[lastvisit]
") and !empty( $dothreads['total'] ) )
{
$count['threads'] = intval( $dothreads['total'] );
$count['threads'] = iif ( $count['threads'] > 0 , numer_format($count['threads']) , 'No' );
$pluralthread = iif ( $count['threads']!=1 , 's' , '' );
}
}

Grunt
05-06-2003, 08:19 PM
nope..still not showing the 'No'

this is where im calling it:

<img src="/bullet.gif">$count[threads] new thread$pluralthread<br />

the $pluralthread is still being called hovever..hmmm

Xenon
05-06-2003, 09:35 PM
try this code then:

$newthreads = '';
if ( $activenewthread )
{
$dothreads = $DB_site->query_first("
SELECT COUNT(*) AS total
FROM thread
WHERE $iforumperms AND dateline>$bbuserinfo[lastvisit]
");
$count['threads'] = intval( $dothreads['total'] );
$count['threads'] = iif ( $count['threads'] > 0 , number_format($count['threads']) , 'No' );
$pluralthread = iif ( $count['threads']!=1 , 's' , '' );
}


after a closer look i think the if tag is senseless and could produce your problem

Grunt
05-07-2003, 07:08 AM
that was it! thanks much..i really appreciate the help :)

Xenon
05-07-2003, 08:30 AM
:)

no problem, you're welcome :)