• Login
  • Register
  • Zoek
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Filebase Entry
  • More Options

ICTscripters

Dé plek voor IT

Dé plek voor IT

Login

Geavanceerde opties
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Dé plek voor IT - ICTscripters
  2. Forum
  3. Scripting & programmeren
  4. PHP + SQL

Forum

  • Ictscripters Chat

    K.Rens 25 februari 2026 om 13:14
  • Help testers nodig voor android app Urgent

    Servertjee 20 februari 2026 om 12:07
  • Partner Gezocht om meerdere NFT Collecties op Open Sea te Plaatsen

    Servertjee 20 februari 2026 om 12:06
  • Afspraken systeem met planbeperking

    Jeffrey.Hoekman 20 februari 2026 om 11:52
  • Developer Gezocht

    Servertjee 19 februari 2026 om 17:31
  • Na 15 jaar terug van weggeweest: iCriminals.nl is terug (BETA)!

    Servertjee 18 februari 2026 om 16:57
  • Op zoek naar de legends

    Syntax 5 januari 2026 om 13:50
  • [FREE] WeFact Hosting module

    Jeroen.G 13 oktober 2025 om 14:09

Marktplaats

  • Meerdere mafia game template te koop

    Syntax 16 februari 2026 om 13:34
  • Verschillende domeinnamen los te koop

    zwpgangster 12 februari 2026 om 16:05
  • Verschillende domeinen

    Syntax 8 februari 2026 om 09:57

Smarty foreach fout

  • Jackie
  • 20 februari 2011 om 03:11
  • Jackie
    Hardstyle
    Berichten
    224
    • 20 februari 2011 om 03:11
    • #1

    Hallo allemaal,

    Ik heb een probleem met smarty.
    Ik heb een foreach met $i--; erin.
    Als ik dit probeer:

    index.php

    PHP
    <?php
    // Copyright Messinagame 2011
    // Created by Youri van Mill
    
    
    require_once $_SERVER['DOCUMENT_ROOT'] . '/inc/configuration.php';
    
    
    if(!isset($_SESSION['name']))
    {
        header('location: /login.php');
        die;
    }
    
    
    $smarty = new Smarty();
    
    
    $smarty->template_dir = 'inc/templates/';
    $smarty->compile_dir = 'inc/templates/compile';
    $smarty->config_dir = 'inc/templates/configs';
    $smarty->cache_dir = 'inc/templates/cache';
    
    
    $smarty->assign('name', $session['name']);
    
    
    $max_items = 2;
    
    
    $begin = ($_GET['p'] >= 0) ? $_GET['p'] * $max_items : 0;
    
    
    // Create the first query
    $stmt = $dbh->query('SELECT * 
                         FROM ' . NEWS_TABLE . '
                         ORDER BY `date` ASC
                         LIMIT ' . $begin . ', ' . $max_items);
    
    
    $result = array();
    
    
    while($res = $stmt->fetch(PDO::FETCH_ASSOC)) 
    { 
        $result[] = $res;
    }
    
    
    $smarty->assign('result', $result);
    
    
    // End the first query
    $stmt = null;
    
    
    // Create the second query
    $stmt = $dbh->query('SELECT * 
                         FROM ' . NEWS_TABLE);
    
    
    $smarty->assign('navigation', range(1, ceil($stmt->rowCount() / $max_items)));
    
    
    // End the second query
    $stmt = null;
    
    
    $smarty->display('index.tpl');
    ?>
    Toon Meer

    index.tpl

    PHP
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    
    <head> 
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> 
      <title> 
      xxxx
      </title> 
     
      <link rel="stylesheet" href="/static/style/style.css" type="text/css" />
      <link rel="stylesheet" href="/static/style/tooltip.css" type="text/css" />
      
      <script src="/static/js/functions.js" type="text/javascript"></script>
    </head> 
    <body>
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
        <tr> 
            <td style="width:14%;vertical-align:top;">
    {include file='menu-left.tpl'}
            </td>
            <td style="width:72%;vertical-align:top;">
                <table style="border:none;width:96%;background:#000000;" align="center" cellpadding="2" cellspacing="1"> 
                    <tr>
                        <td class="header"> 
                            &nbsp;
                        </td>
                    </tr>
                    <tr> 
                        <td class="subheader">
                            <table style="border:none;width:100%;margin:0px;" cellspacing="0" cellpadding="0"> 
                                <tr>
                                    <td style="text-align:left;">
                                        Welkom terug {$name|ucfirst}.
                                    </td>
                                    <td style="text-align:right;">
                                        <b>Je kan weer stemmen voor 100 kogels!</b>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <br />
                <table style="border:none;width:60%;background:#000000;" align="center" cellpadding="2" cellspacing="1">
                    <tr> 
                        <td class="textTitle">
                            Nieuws pagina
                        </td> 
                    </tr>
    {foreach $result as $res}
                    <tr>  
                        <td class="text"> 
                            <span style="font-size:20px;">{$res.title|ucfirst}</span>
                            <br />
                            <span style="font-size:10px;">Geschreven op {$res.date|date_format:'%d %B %Y om %H:%S'}</span>
                            <br />
                            {$res.message|stripslashes}
                        </td>
                    </tr>
    {foreachelse}
                    <tr>  
                        <td class="text"> 
                            Er nog geen nieuws.
                        </td>  
                    </tr>
    {/foreach}
                    <tr>
                        <td class="text">
                            Pagina 
    {foreach $navigation as $i}
        {$i--}
                            <a href="/index.php?={$i}">{($i+1)}</a>
    {/foreach}
                        </td>
                    </tr>
                </table>
                <br />
                <center>Copyright Messinagame 2011</center>
            </td>
            <td style="width:14%;vertical-align:top;">
    {include file='menu-right.tpl'}
            </td>
        </tr>
    </table>
    </body>
    </html>
    Toon Meer

    Er staan 6 nieuwsberichten in de database (dus 6 records)

    Ik heb LIMIT op 2 gezet dus hij laat er dan maar 2 zien dat werkt.

    Hij zou dus eigenlijk dit moeten weergeven:

    PHP
    Pagina 1 2 3

    Maar hij laat dit zien:

    PHP
    Pagina 1 1 2 2 3 3

    Wat doe ik fout, wie kan me helpen?

    Bezig met een zelf gemaakte source, geschreven vanaf 0 natuurlijk!

  • Guest, wil je besparen op je domeinnamen? (ad)
  • Darsstar
    Vreemd
    Berichten
    1.173
    • 20 februari 2011 om 12:23
    • #2
    PHP
    {foreach $navigation as $i}
                            <a href="/index.php?={($i-1)}">{$i}</a>
    {/foreach}

    Zo misschien?
    Ik weet niet veel van smarty, maar het lijkt me dat {$i--} geprint werd.

    miauw!

  • Jackie
    Hardstyle
    Berichten
    224
    • 20 februari 2011 om 13:01
    • #3

    Dankjewel hij werkt nou :)

    Bedankt!

    :slotje:

    Bezig met een zelf gemaakte source, geschreven vanaf 0 natuurlijk!

Participate now!

Heb je nog geen account? Registreer je nu en word deel van onze community!

Maak een account aan Login

ICT Nieuws

  • DeepSeek traint nieuw AI-model op Nvidia Blackwell-chips ondanks Amerikaanse ban

    ICTscripters 25 februari 2026 om 12:25
  • 🏷️ Amazon: Russisch-talige hacker gebruikte AI om firewalls te hacken

    ICTscripters 23 februari 2026 om 20:19
  • AI-arbeidsmarkt 2026: Nederlandse techsector kampt met recordvraag naar AI-talent

    K.Rens 22 februari 2026 om 20:56

Blogs

  • Functioneel ontwerp

    Dees 28 december 2014 om 12:38
  • Access Control List implementatie in PHP/MySQL - deel 1/2

    FangorN 28 december 2018 om 12:35
  • Access Control List implementatie in PHP/MySQL - deel 2/2

    FangorN 29 december 2018 om 12:37

Gebruikers die dit topic bekijken

  • 1 Gasten
  1. Marktplaats
  2. Design
  3. Voorwaarden
  4. Ons team
  5. Leden
  6. Geschiedenis
  7. Regels
  8. Links
  9. Privacy Policy
ICTscripters ©2005 - 2026 , goedkope hosting door DiMoWeb.com, BE0558.915.582
Sponsors: Beste kattenhotel provincie Antwerpen | Beste Zetes eid kaartlezer webshop
Style: Nexus by cls-design
Stylename
Nexus
Manufacturer
cls-design
Licence
Commercial styles
Help
Supportforum
Visit cls-design