Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Problemy z petlami...

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish
View previous topic :: View next topic  
Author Message
d3d!k
Smarty n00b


Joined: 23 Nov 2008
Posts: 1

PostPosted: Tue Dec 23, 2008 6:26 pm    Post subject: Problemy z petlami... Reply with quote

Witam, mam następujący kod:

Code:
   $catdata = $db->cache('read', 'cat_data');
   $cat_id = $db->cache('read', 'cat_data_id');
   if (!$catdata || !$cat_id)
   {


      $sql = "SELECT cat_id, cat_title, cat_desc, cat_order FROM " . CATEGORIES_TABLE . " ORDER BY cat_order DESC";
      $result = $db->query($sql);
      while ($row = $db->fetch($result))
      {
         $catdata[] = Array(
                  'id'=>$row[cat_id],
                  'desc'=>$row[cat_desc],
                  'name'=>bbcode($row[cat_title])
               );
         $cat_id[] = $row[cat_id];
      }
      $db->cache('write', 'cat_data', $catdata);
      $db->cache('write', 'cat_data_id', $cat_id);
   }

   for($i=0; $i<count($cat_id); $i++)
   {
      $sql = "SELECT f.*, t.topic_id, t.topic_title, t.topic_desc, t.topic_time, t.topic_poster, u.user_id as user_id_topic, u.user_username as username_topic, u2.user_id as user_id_post, u2.user_rank as user_rank, u2.user_username as username_post, u2.user_rank as user_2rank, p.post_id, p.post_subject, p.post_text, p.poster_id, p.post_time, p2.topic_id, p2.post_text as topic_text
         FROM ((((( " . FORUMS_TABLE . " f
         LEFT JOIN " . TOPICS_TABLE . " t ON t.topic_id = f.forum_last_topic_id )
         LEFT JOIN " . POSTS_TABLE . " p2 ON p2.topic_id = f.forum_last_topic_id )
         LEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )
         LEFT JOIN " . USERS_TABLE . " u ON u.user_id = t.topic_poster )
         LEFT JOIN " . USERS_TABLE . " u2 ON u2.user_id = p.poster_id )
         WHERE f.cat_id = '".$cat_id[$i]."' AND f.parent_id = 0 ORDER BY f.forum_order";
      $result = $db->query($sql);
      while ($row = $db->fetch($result))
      {
         $forumdata[$i][] = Array(
                     'id'=>$row[forum_id],
                     'cid'=>$row[cat_id],
                     'name'=>bbcode($row[forum_name]),
                     'posts'=>$row[forum_posts],
                     'topics'=>$row[forum_topics],
                     'desc'=>bbcode($row[forum_desc]),
                     'username_topic'=> security($row[username_topic]),
                     'color_username_topic'=> color_username($row[user_id_topic],security($row[username_topic]),$row[user_rank]),
                     'topic_id'=>$row[topic_id],
                     'topic_name'=>substr(bbcode($row[topic_title]), 0, 24) . ((strlen(bbcode($row[topic_title])) > 24) ? ',,,' : ''),
                     'topic_desc'=>bbcode($row[topic_desc]),
                     'topic_text'=> substr(bbcode($row[topic_text]), 0, 260) . ((strlen(bbcode($row[topic_text])) > 260) ? '...' : ''),
                     'topic_time'=>date('d/m/y, H:i', $row[topic_time]),
                     'username_post' => security($row[username_post]),
                     'color_username_post' => color_username($row[user_id_post],security($row[username_post]),$row[user_2rank]),
                     'post_id'=>$row[post_id],
                     'post_subject'=>substr(bbcode($row[post_subject]), 0, 24) . ((strlen(bbcode($row[post_subject])) > 24) ? ',,,' : ''),
                     'post_text'=> substr(bbcode($row[post_text]), 0, 260) . ((strlen(bbcode($row[post_text])) > 260) ? '...' : ''),
                     'post_time'=>date('d/m/y, H:i', $row[post_time]),
                  );
      }
   }

   $template_tpl->assign("forumdata", $forumdata);
   $template_tpl->assign("catdata", $catdata);


i chciałbym teraz zrobić pokazywanie subfor dla danych for, robie wszystko wedlug schematu i nie działa ma ktoś może jakiś pomysł ? :/

Proszę o odpowiedź Smile
Back to top
View user's profile Send private message
Onedamobamomi
Smarty n00b


Joined: 08 Jul 2011
Posts: 4
Location: Greenland

PostPosted: Sat Oct 08, 2011 11:50 am    Post subject: Problemy z petlami Reply with quote

moj kolega chce się zarejestrować na forum lecz nie może bo gdy wypełnia dane wszystkie pisze że Kod potwierdzajacy jest za krótki a tam nawet nie ma kodu ani tabelki zeby go wpisać, probowalem pisac pw modowi lecz tez jakies problemy byly wiec pisze tu.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP