Hallo
muss das Thema mal eben aufgreifen, weil ich es versucht habe und es hat nicht geklappt.
Ich würde es gern so haben wie ganz oben beschrieben.
Also eine Box, die nur nur die Posts einer bestimmten Kategorie ausgibt. In dem Fall ist die Kateogorie Marktplatz->Biete die als ID 45 in der SQL Datenbank eingetragen ist.
Leider zeigt mir die Box folgendes an, anstatt der letzten 5 Posts.
MySQL Error:
1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY c.time DESC LIMIT 0,5' at line 17
in Query:
SELECT a.id, a.name, a.rep, c.erst as last, c.id as pid, c.time FROM ic2_topics a LEFT JOIN ic2_forums b ON b.id = a.fid LEFT JOIN ic2_forumcats F ON F.id = b.cid LEFT JOIN ic2_posts c ON c.id = a.last_post_id LEFT JOIN ic2_groupusers vg ON vg.uid = 1 AND vg.gid = b.view LEFT JOIN ic2_groupusers rg ON rg.uid = 1 AND rg.gid = b.reply LEFT JOIN ic2_groupusers sg ON sg.uid = 1 AND sg.gid = b.start WHERE ((-9 <= b.view AND b.view < 1) OR (-9 <= b.reply AND b.reply < 1) OR (-9 <= b.start AND b.start < 1) OR vg.fid IS NOT NULL OR rg.fid IS NOT NULL OR sg.fid IS NOT NULL OR -9 >= -9 AND F.cid = '45' ORDER BY c.time DESC LIMIT 0,5
Debug backtrace:
@ mysql.php:32 -- debug_bt()
@ mysql.php:50 -- db_check_error(...)
@ marktplatz.php:26 -- db_query(...)
@ design.php:332 -- require_once(...)
@ design.php:254 -- design->get_boxcontent(...)
@ design.php:46 -- design->get_boxes(...)
@ show_cat.php:11 -- design->design(...)
@ forum.php:129 -- require_once(...)
@ index.php:24 -- require_once(...)
Was ist da jetzt falsch ???
Hier mal schnell die Box... habs gemacht, wie beschrieben.
<?php
# Copyright by Manuel
# Support www.ilch.de
defined ('main') or die ( 'no direct access' );
$query = "SELECT a.id, a.name, a.rep, c.erst as last, c.id as pid, c.time
FROM prefix_topics a
LEFT JOIN prefix_forums b ON b.id = a.fid
LEFT JOIN prefix_forumcats F ON F.id = b.cid
LEFT JOIN prefix_posts c ON c.id = a.last_post_id
LEFT JOIN prefix_groupusers vg ON vg.uid = ".$_SESSION['authid']." AND vg.gid = b.view
LEFT JOIN prefix_groupusers rg ON rg.uid = ".$_SESSION['authid']." AND rg.gid = b.reply
LEFT JOIN prefix_groupusers sg ON sg.uid = ".$_SESSION['authid']." AND sg.gid = b.start
WHERE ((".$_SESSION['authright']." <= b.view AND b.view < 1)
OR (".$_SESSION['authright']." <= b.reply AND b.reply < 1)
OR (".$_SESSION['authright']." <= b.start AND b.start < 1)
OR vg.fid IS NOT NULL
OR rg.fid IS NOT NULL
OR sg.fid IS NOT NULL
OR -9 >= ".$_SESSION['authright']."
AND F.cid = '45'
ORDER BY c.time DESC
LIMIT 0,5";
echo '<table>';
$resultID = db_query($query);
while ($row = db_fetch_assoc($resultID)) {
$row['date'] = date('d.m.y - H:i',$row['time']);
$row['page'] = ceil ( ($row['rep']+1) / $allgAr['Fpanz'] );
echo '<tr><td valign="top"><b> » </b></td><td><a href="?forum-showposts-'.$row['id'].'-p'.$row['page'].'#'.$row['pid'].'" title="'.$row['date'].'">'.((strlen($row['name'])<18) ? $row['name'] : substr($row['name'],0,15).'...').'<br /><span class="smalfont"> von '.$row['last'].'</span></a></td></tr>';
}
echo '</table>';
?>
Weiß einer nen Rat ???