|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
marcus-24-d Smarty n00b
Joined: 01 Apr 2013 Posts: 2
|
Posted: Mon Apr 01, 2013 2:09 pm Post subject: Need help to create a commentbox |
|
|
Hey there. Im German and i hope you can understand my context
i want to create a comment box like facebook.
users can create a new post an others can comment it.
i have problems to create an array for this.
i have 3 tables
Tabelle 1 = Threads
Tabelle 2 = Comments
Tabelle 3 = Users
t1 = id,userid,ins_time,message,type,type_value
t2 = thread_id,comment_userid,comment_time_comment_message
t3 = id,username
if i use the array for the threads, so i get always only one comment for a thread, because i havent a way to get all results from the query.
PHP
Code: | $threads = $osDB->getAll('select * from ! where content = ? order by ins_time asc limit 0,30', array( THREAD_TABLE, 1 ) );
$comments = $osDB->getAll('select * from ! where thread_id = ? order by ins_time asc', array( COMMENT_TABLE, $threads['id'] ) );
$t->assign('threads',$threads);
$t->assign('comments',$comments); |
SMARTY
Code: |
<!-- threads -->
{foreach item=item from=$threads}
<div style="width:480px; min-height:100px; height:auto; border:#FFF 1px solid; text-align:left;">
<div style="float:left; width:430px;">
<div class="font11" style="float:left; width:250px; height:15px;"><strong>{$item.username}</strong> {$item.ins_time} </div>
</div>
<div class="color_black" style="float:left; width:430px; min-height:50px; height:auto; margin-top:5px;"><!--youtube einbetten --><!-- message -->
{$item.message}
<!-- comments view -->
<div class="color_black" style="padding:2px; float:left; width:430px; min-height:20px; height:auto; margin-bottom:3px; margin-top:10px; border-bottom:#CCC 1px solid;"><span class="fontsize16">Comments</span></div>
{foreach item=item from=$comments}
<div class="color_black" style="padding:2px; float:left; width:430px; min-height:30px; height:auto; margin-top:1px; background-color:#E8E8FF;">
<div class="font11" style="float:left; width:375px; margin-top:5px;"><strong>{$item.username}</strong></div>
<div style="float:left; width:375px;">
{$item.message}<br />
</div>
<div style="clear:both; line-height:0; heigt:0;"></div>
</div>
{/foreach}
<!-- end comments view -->
</div>
<div style="clear:both; line-height:0; heigt:0;"></div>
<div style="width:480px; height:1px; border-bottom: #999 1px dotted;margin-top:15px; margin-bottom:15px;"></div>
</div>
{/foreach} |
im tryed it with a foreach.
hope u can help. if german guys is here, so tell me please
thank you. Marcus |
|
Back to top |
|
marcus-24-d Smarty n00b
Joined: 01 Apr 2013 Posts: 2
|
Posted: Mon Apr 01, 2013 4:55 pm Post subject: |
|
|
i have it now..close pls |
|
Back to top |
|
|
|
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
|