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

foreach with too much entries

 
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 -> General
View previous topic :: View next topic  
Author Message
demo1987
Smarty Rookie


Joined: 16 Apr 2014
Posts: 9

PostPosted: Wed Apr 16, 2014 1:28 pm    Post subject: foreach with too much entries Reply with quote

Hello,

i have a little problem with the foreach method. i have too much entries in my table but i donīt know why.

in my php file i set this vars:

Code:
// get all missions
    $getMissions = $db->query("SELECT * FROM eos_missions ORDER BY ID ASC") or SQLError();
    while($missions_eintrag = $getMissions->fetch_assoc()) {
        $getDispatchNum = $db->query(sprintf("SELECT * FROM eos_dispatches WHERE mission_id = %s", Secure($missions_eintrag['id'], 'int') )) or SQLError();
        $missions['dispatchNum'] = $getDispatchNum->num_rows;
        $missions[] = $missions_eintrag;
    }
   $smarty->assign('missionsNum', $getMissions->num_rows);
   $smarty->assign('dispatchNum', $missions['dispatchNum']);
    $smarty->assign('missions', $missions);


in my tpl file i generate this table:

Code:
...
<tbody>
                            {foreach $missions as $missions_eintrag}
                               <tr>
                                    <td class="text-center"><input type="checkbox" id="checkbox1-1" name="checkbox1-1"></td>
                                    <td class="text-center">{$missions_eintrag.id}</td>
                                    <td>{$missions_eintrag.created_at|date_format:"%d.%m.%Y, %H:%M:%S"}</td>
                                    <td><a href="../admin/mission.php?id={$missions_eintrag.id}">{$missions_eintrag.title}</a></td>
                                    <td>{$dispatchNum}</td>
                                    <td class="text-center">
                                        <div class="btn-group btn-group-xs">
                                            <a href="../admin/editmission.php?do=edit&id={$missions_eintrag.id}" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="Bearbeiten"><i class="fa fa-pencil"></i></a>
                                            <a href="../admin/editmission.php?do=delete&id={$missions_eintrag.id}" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="L&ouml;schen"><i class="fa fa-times"></i></a>
                                        </div>
                                    </td>
                                </tr>{/foreach}
                            </tbody>
...


i should see 2 dispatches at one mission and i got a empty row with only one dispatch:


what do i wrong
Back to top
View user's profile Send private message
demo1987
Smarty Rookie


Joined: 16 Apr 2014
Posts: 9

PostPosted: Fri Apr 18, 2014 7:07 am    Post subject: Reply with quote

sorry i solved it, it was an error in my sql queries
Back to top
View user's profile Send private message
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 -> General 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