Hi erstmal,
ich habe folgende Probleme:
1. Problem: Themen sortieren
Ich programmiere momentan eine Forensoftware und er soll nun die Themen nach dem Datum sortieren.
Das ist ja nicht weiter schwer, aber nun kommt das Problem. Er soll zugleich gucken, ob ein Post zum
Thema vorhanden ist und dann schauen, ob dieser ein "neueres" Datum hat, als das neuste Themen und
dieses dann so anordnen.
Hier meine aktuelle SQL Abfrage, die allerdings nicht funktioniert, bzw. nicht das tut was ich möchte:
Alles anzeigen
Und hier ein Link zu dem Problem "live":
voltic-board.de/forum-1
Man sieht ein Thema, das neuer ist als das erste, welches eine Antwort hat, die allerdings auch
nicht neuer ist als das neue Thema.
2. Problem: (Un)gelesen Funktion
Zudem mache ich eine Thema ungelesen/gelesen Funktion.
Nun ist mein Problem folgendes.
Er zeigt immer nur ein ungelesenes Thema (in diesem Falle 1 vons 3) an.
Hier mein Code:
Alles anzeigen
Bitte um schnelle Hilfe!
Danke im VOrraus.
Gruß,
Lars
ich habe folgende Probleme:
1. Problem: Themen sortieren
Ich programmiere momentan eine Forensoftware und er soll nun die Themen nach dem Datum sortieren.
Das ist ja nicht weiter schwer, aber nun kommt das Problem. Er soll zugleich gucken, ob ein Post zum
Thema vorhanden ist und dann schauen, ob dieser ein "neueres" Datum hat, als das neuste Themen und
dieses dann so anordnen.
Hier meine aktuelle SQL Abfrage, die allerdings nicht funktioniert, bzw. nicht das tut was ich möchte:
Quellcode
- $sql3 = "SELECT
- a.`thread_title`,
- a.`thread_date`,
- a.`thread_autor`,
- a.`thread_closed`,
- a.`thread_id`,
- b.`user_name`,
- b.`user_id`,
- (SELECT c.`post_date` FROM `".$praefix."_post` AS c WHERE c.`post_thread_id` = a.`thread_id` ORDER BY c.`post_date` DESC LIMIT 1) AS `date`
- FROM
- `".$praefix."_thread` AS a
- LEFT JOIN
- `".$praefix."_user` AS b
- ON
- a.`thread_autor` = b.`user_name`
- WHERE
- a.`thread_board_id` = '".mysql_real_escape_string($row2['board_id'])."'
- ORDER BY
- `date` DESC,
- a.`thread_date` DESC
- LIMIT
- 1";
Und hier ein Link zu dem Problem "live":
voltic-board.de/forum-1
Man sieht ein Thema, das neuer ist als das erste, welches eine Antwort hat, die allerdings auch
nicht neuer ist als das neue Thema.
2. Problem: (Un)gelesen Funktion
Zudem mache ich eine Thema ungelesen/gelesen Funktion.
Nun ist mein Problem folgendes.
Er zeigt immer nur ein ungelesenes Thema (in diesem Falle 1 vons 3) an.
Hier mein Code:
Quellcode
- <?php
- //...
- while($row2 = $result2->fetch()) {
- $sql3 = "SELECT
- a.`thread_title`,
- a.`thread_date`,
- a.`thread_autor`,
- a.`thread_closed`,
- a.`thread_id`,
- b.`user_name`,
- b.`user_id`,
- (SELECT c.`post_date` FROM `".$praefix."_post` AS c WHERE c.`post_thread_id` = a.`thread_id` ORDER BY c.`post_date` DESC LIMIT 1) AS `date`
- FROM
- `".$praefix."_thread` AS a
- LEFT JOIN
- `".$praefix."_user` AS b
- ON
- a.`thread_autor` = b.`user_name`
- WHERE
- a.`thread_board_id` = '".mysql_real_escape_string($row2['board_id'])."'
- ORDER BY
- `date` DESC,
- a.`thread_id` DESC
- LIMIT
- 1";
- $result3 = new Query($sql3);
- $row3 = $result3->fetch();
- $sql5 = "SELECT * FROM ".$praefix."_post WHERE post_thread_id = ".$row3['thread_id'];
- $result5 = new Query($sql5);
- $num5 = $result5->numRows();
- if ($num5 != 0) {
- if (strlen($row3['thread_title']) > 25) {
- $threadtitel = "Re: ".substr($row3['thread_title'],0,20)."...";
- }
- else {
- $sql6 = "SELECT * FROM ".$praefix."_thread WHERE thread_board_id = ".$row2['board_id'];
- $result6 = new Query($sql6) or die(mysql_error());
- $numRow6 = $result6->numRows();
- if ($numRow6 == 0) {
- $threadtitel = "";
- }
- else {
- $threadtitel = "Re: ".$row3['thread_title'];
- }
- }
- }
- else {
- if (strlen($row3['thread_title']) > 25) {
- $threadtitel = substr($row3['thread_title'],0,23)."...";
- }
- else {
- $threadtitel = $row3['thread_title'];
- }
- }
- if (!isset($_SESSION["user_id"])) {
- $smarty->assign("on_closed_off",'<img src="images/off.gif" alt="Nichts neues" />');
- }
- else {
- if ($row3['thread_closed'] == 1) {
- $smarty->assign("on_closed_off",'<img src="images/closed.gif" alt="Gesperrt" />');
- }
- else {
- $sql4 = "SELECT * FROM ".$praefix."_unread_topic WHERE unread_user_id = ".$_SESSION['user_id'];
- $result4 = new Query($sql4) or die(mysql_error());
- if ($result4->numRows() == 0) {
- $smarty->assign("on_closed_off",'<img src="images/off.gif" alt="Nichts neues" />');
- }
- else {
- while($row4 = $result4->fetch()) {
- if ($row4['unread_thread_id'] == $row3['thread_id'] or $row4['unread_post_thread'] == $row3['thread_id']) {
- $smarty->assign("on_closed_off",'<img src="images/on.gif" alt="Neu" />');
- }
- else {
- if ($row3['thread_closed'] == 1) {
- $smarty->assign("on_closed_off",'<img src="images/closed.gif" alt="Gesperrt" />');
- }
- else {
- $smarty->assign("on_closed_off",'<img src="images/off.gif" alt="Nichts neues" />');
- }
- }
- }
- }
- }
- }
- $smarty->assign("boardid",$row2["board_id"]);
- $smarty->assign("boardtitle",$row2["board_title"]);
- $smarty->assign("boarddescription",$row2["board_description"]);
- $smarty->assign("boardthread",$threadtitel);
- $smarty->assign("threadid",$row3["thread_id"]);
- $smarty->assign("userid",$row3["user_id"]);
- $smarty->assign("boardautor",$row3["user_name"]);
- $smarty->display('index_board.tpl');
- }
- }
- //...
- ?>
Bitte um schnelle Hilfe!
Danke im VOrraus.
Gruß,
Lars