Abfrage der Gesamtanzahl von Knowledgebase-Artikel
- Maidenaustria
- Mitglied
- Beiträge: 187
- Registriert: 01.04.2005 19:06
- Wohnort: Wien
- Kontaktdaten:
Abfrage der Gesamtanzahl von Knowledgebase-Artikel
Ich hab diese Frage schon im Modding-Forum gepostet, jedoch komm ich da nicht weiter!
Ich will, ähnlich der Anzeige der Anzahl aller Postings, eine Anzeige der Anzahl aller Artikel in der Knowledgebase machen.
Kann mir da jemand helfen?
Bitte - Danke!
Die österreichische Iron Maiden Fan - Community
Code: Alles auswählen
SELECT COUNT(*) FROM deine_tabelle
Mein eigenes kleines Forum: http://forum.sw-rpg.de
die funktion
Code: Alles auswählen
function get_db_stat($mode)
Code: Alles auswählen
$total_posts = get_db_stat('postcount');
- Maidenaustria
- Mitglied
- Beiträge: 187
- Registriert: 01.04.2005 19:06
- Wohnort: Wien
- Kontaktdaten:
Vorest einmal vielen Dank für eure Tipps und etwas zum weiteren Verständniss.
Ich bin ein Absoluter php-Anfänger, also wenn in den folgenden Zeilen der Ultra-Schwachsinn zu lesen ist - bitte nicht steinigen!
Ich hab mir das in der Art so rausgepickt:
In die functions.php ab Zeile 73:
Code: Alles auswählen
function get_db_stat($mode)
{
global $db;
switch( $mode )
{
case 'countarticles':
$sql = "SELECT COUNT(article_id) AS total
FROM " . KB_ARTICLES_TABLE . "
WHERE article <> " . ANONYMOUS;
break;
}
if ( !($result = $db->sql_query($sql)) )
{
return false;
}
$row = $db->sql_fetchrow($result);
switch ( $mode )
{
case 'countarticles':
return $row['total'];
break;
}
return false;
}
In die index.php ab Zeile 280:
Code: Alles auswählen
$total_kbarticles = get_db_stat('countarticles');
Code: Alles auswählen
if( $total_kbarticles == 0 )
{
$l_total_kbarticles_s = $lang['Kbarticles_zero_total'];
}
else if( $total_kbarticles == 1 )
{
$l_total_kbarticles_s = $lang['Kbarticles_total'];
}
else
{
$l_total_kbarticles_s = $lang['Kbarticle_total'];
}
und in Zeile 649:
Code: Alles auswählen
'TOTAL_KBArticles' => sprintf($l_total_kbarticles_s, $total_kbarticles),
und in der lang_main.php:
Code: Alles auswählen
$lang['Kbarticles_zero_total'] = 'Our KB has <b>0</b> articles'; // Number of posts
$lang['Kbarticles_total'] = 'Our KB has <b>%d</b> articles'; // Number of posts
$lang['Kbarticle_total'] = 'Our KB has <b>%d</b> article'; // Number of posts
Kann mir jemand sagen ob ich da annähnernd etwas dabei herausbekomme???
PS: Das ANONYNOUS kommt mir noch etwas seltsam vor...
Die österreichische Iron Maiden Fan - Community
FIND /includes/functions.php
Code: Alles auswählen
case 'usercount':
$sql = "SELECT COUNT(user_id) AS total
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS;
break;
Code: Alles auswählen
case 'countarticles':
$sql = "SELECT COUNT(article_id) AS total
FROM " . KB_ARTICLES_TABLE;
break;
Also wie bei dir, aber ohne "where" - keine Ahnung wofür Du das brauchst

FIND
Code: Alles auswählen
case 'usercount':
return $row['total'];
break;
Code: Alles auswählen
case 'countarticles':
return $row['total'];
break;

- Maidenaustria
- Mitglied
- Beiträge: 187
- Registriert: 01.04.2005 19:06
- Wohnort: Wien
- Kontaktdaten:
Hab ja auch keine Ahnung - so weit kenn ich mich nicht aus (Hab Euch aber gewarntbazillus hat geschrieben:Also wie bei dir, aber ohne "where" - keine Ahnung wofür Du das brauchst

Egal, ich werde es testen und geb Euch Bescheid!
Vielen Dank einstweilen und bis später!
Die österreichische Iron Maiden Fan - Community
- Maidenaustria
- Mitglied
- Beiträge: 187
- Registriert: 01.04.2005 19:06
- Wohnort: Wien
- Kontaktdaten:
Nur bei der Abfrage an die DB dürfte noch was faul sein....
Bei der Abfrage dürfte nix herauskommen, denn von:
Code: Alles auswählen
if( $total_kbarticles == 0 )
{
$l_total_kbarticles_s = $lang['Kbarticles_zero_total'];
}
else if( $total_kbarticles == 1 )
{
$l_total_kbarticles_s = $lang['Kbarticles_total'];
}
else
{
$l_total_kbarticles_s = $lang['Kbarticle_total'];
}
Bekomme ich immer die Variable
Code: Alles auswählen
$lang['Kbarticles_zero_total']
Also faktisch:
Code: Alles auswählen
$lang['Kbarticles_zero_total'] = 'Die Enzyklopädie beinhaltet <b>0</b> Releases'; // Number of posts
obwohl ~500 Artikel online sind...
Die österreichische Iron Maiden Fan - Community
- Maidenaustria
- Mitglied
- Beiträge: 187
- Registriert: 01.04.2005 19:06
- Wohnort: Wien
- Kontaktdaten:
Muss die Tabelle durchgehend sein?
Die österreichische Iron Maiden Fan - Community
quick&dirty
öffne includes/constants.php
FIND
Code: Alles auswählen
define('VOTE_USERS_TABLE', $table_prefix.'vote_voters');
Code: Alles auswählen
define('KB_ARTICLES_TABLE', $table_prefix.'kb_articles');

Nein.Maidenaustria hat geschrieben:Kann es sein das es nicht funktioniert weil meine Article ID erst bei 5 beginnt???
Muss die Tabelle durchgehend sein?
suche:
mal ein ganz neuer Ansatz...
öffne: includes/functions.php
suche:
Code: Alles auswählen
case 'usercount':
$sql = "SELECT COUNT(user_id) AS total
FROM " . USERS_TABLE . "
WHERE user_id <> " . ANONYMOUS;
break;
Code: Alles auswählen
case 'totalkb':
$sql = "SELECT article_id
FROM " . KB_ARTICLES_TABLE;
break;
Code: Alles auswählen
$row = $db->sql_fetchrow($result);
Code: Alles auswählen
if( $mode == 'totalkb' )
{
$total = $db->sql_numrows($result);
}
else
{
$row = $db->sql_fetchrow($result);
}
Code: Alles auswählen
case 'topiccount':
return $row['topic_total'];
break;
Code: Alles auswählen
case 'totalkb':
return intval($total);
break;
statt:
Code: Alles auswählen
$total_kbarticles = get_db_stat('countarticles');
Code: Alles auswählen
$total_kbarticles = get_db_stat('totalkb');
Code: Alles auswählen
if( $total_kbarticles == 0 )
{
$l_total_kbarticles_s = $lang['Kbarticles_zero_total'];
}
else if( $total_kbarticles == 1 )
{
$l_total_kbarticles_s = $lang['Kbarticles_total'];
}
else
{
$l_total_kbarticles_s = $lang['Kbarticle_total'];
}
Code: Alles auswählen
if( $total_kbarticles == 1 )
{
$l_total_kbarticles_s = $lang['Kbarticle_total'];
}
else if( $total_kbarticles > 1 )
{
$l_total_kbarticles_s = sprintf($lang['Kbarticles_total'], $total_kbarticles);
}
else
{
$l_total_kbarticles_s = $lang['Kbarticles_zero_total'];
}
Code: Alles auswählen
'TOTAL_KBArticles' => sprintf($l_total_kbarticles_s, $total_kbarticles),
Code: Alles auswählen
'TOTAL_KBArticles' => $l_total_kbarticles_s,
Code: Alles auswählen
$lang['Kbarticles_zero_total'] = 'Our KB has <b>0</b> articles'; // Number of posts
$lang['Kbarticles_total'] = 'Our KB has <b>%s</b> articles'; // Number of posts
$lang['Kbarticle_total'] = 'Our KB has <b>one</b> article'; // Number of posts
