Seite 2 von 2

Verfasst: 06.05.2003 14:56
von Acid
..und wenn Du cat_id = 1 AND cat_id = 5 in die Where-Klausel einfügst... des funktioniert nich ?

Ansonsten schreib ma dem Autoren ´ne Mail, der is eigentlich ganz in Ordnung und wird dir weiterhelfen, wenn er kann.

Verfasst: 06.05.2003 15:00
von Chaze

Code: Alles auswählen

..und wenn Du cat_id = 1 AND cat_id = 5 in die Where-Klausel einfügst... des funktioniert nich ? 
Nee, hab ich schon probiert, leider.
Aber einen hab ich noch. Ich werde mal versuchen in der content.php die Funktionen in ein foreach zu packen, so dass die Funktion für jedes Element im Array einmal ausgeführt wird. (<-- Strohhalm :roll: )

Verfasst: 06.05.2003 16:57
von Chaze
* Chaze klopft sich selber auf die Schulter und freut sich, dass er doch nicht so doof ist...

Der Schlüssel lag in der Funktion get_cat:
function get_cat($cat_id)
{

global $db;

// vérifier la catégorie
if ($cat_id <= 0) $cat_id = -1;
if ($cat_id > 0)
{
$sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id = 1 OR cat_id = 3";
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query this categories A', '', __LINE__, __FILE__, $sql);
if ( !($row = $db->sql_fetchrow($result)) ) $cat_id = -1;
}
//
// no cat selected : get all
if ($cat_id <= 0)
{
//-- v 1.0.5
$sql = "SELECT * FROM " . CATEGORIES_TABLE . " WHERE cat_id = 1 OR cat_id = 3 ORDER BY cat_order";
//--
if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list B', '', __LINE__, __FILE__, $sql);
while ( $row = $db->sql_fetchrow($result) ) $category_rows[] = $row;
}
//
// a cat selected : get it and its sub-cats
if ($cat_id > 0)
{
// add the current one
$catrow[] = $row;
// get sub-cats
$catrow = get_sub_cat($cat_id,$catrow);
// get cats
//-- v 1.0.5
$sql = "SELECT * FROM " . CATEGORIES_TABLE . " ORDER BY cat_order";
//--
if( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, 'Could not query categories list C', '', __LINE__, __FILE__, $sql);
while ($row = $db->sql_fetchrow($result) )
{
$found = false;
for ($i=0;( $i<count($catrow) && (!$found) );$i++) $found = ($row['cat_id'] == $catrow[$i]['cat_id']);
if ($found) $category_rows[] = $row;
}
}
return $category_rows;
}
Mit OR anstatt mit AND funktioniert es.

Verfasst: 07.05.2003 19:59
von saerdnaer
und mit WHERE cat_id IN( 1, 3 )

ah

Verfasst: 07.05.2003 20:12
von Chaze
Ahhh...wesentlich eleganter :o

Hattest Du nicht mal den (durchaus berechtigten) Rang phpBB-Jesus? :wink:

Verfasst: 07.05.2003 20:15
von saerdnaer
den hab ich auch jetzt noch... nur bin ich noch weiter aufgestiegen... zum phpbb.de modder... somit hab ich hier moderatoren rechte ;-)