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

Smarty and Count

 
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 -> Help Wanted (commercial)
View previous topic :: View next topic  
Author Message
ptnetwork
Smarty n00b


Joined: 09 Jul 2009
Posts: 1

PostPosted: Thu Jul 09, 2009 5:40 pm    Post subject: Smarty and Count Reply with quote

Hello I`m new to smarty and i have a problem...
I check how many users are in each group

without smarty my code looks like this and was placed in my tpl

Code:

  while($field = mysql_fetch_array($result))
  {
    $id = $field["id"];
    $name = $field["name"];
    if(isset($field["description"]) && empty($field["description"])) $description = "Keine Angabe";
    else $description = $field["description"];
   
    $result2 = db_qry("SELECT COUNT(*) as Anzahl FROM `ptn_users` WHERE `group`='".$id."'");
    $row = mysql_fetch_assoc($result2);
   
    echo'<tr class="row">
               <td class="row" class="row">'.$id.'</td>
               <td class="row">'.$name.'</td>
               <td class="row">'.$row["Anzahl"].'</td>
               <td class="row">'.$description.'</td>
               <td class="row" style="text-align: center;"><a href="admin.php?mode=groups&amp;action=edit&amp;id='.$field["id"].'"><img src="public/images/admin/icon_edit.png" alt="" /></a></td>
            </tr>';
  }



But how can i translate it into smarty?
i tryed following in my php area but it wont work

Code:

  if(isset($_GET["action"])) $action = $_GET["action"];
  else $action = "main";

  switch($action)
  {
    default:
   
    $result = db_qry("SELECT * FROM `ptn_groups`");
   
   $table_data = array();
       while ($row = mysql_fetch_assoc($result))
       {
       array_push($table_data, array(
      'gid' => $row['gid'],
      'name' => $row['name'],
      'description' => $row['description']
      )
            );
   }

   $result2 = db_qry("SELECT COUNT(*) as Anzahl FROM `ptn_users` WHERE `group`='".$row['gid']."'");
    $count = mysql_fetch_assoc($result2);
   
    
   $smarty->assign('modul', 'Gruppenverwaltung <!-- [ <a href ="admin.php?mode=groups&amp;action=new">NEU</a> ] -->');
   $smarty->assign('gruppe', 'Gruppe');
   $smarty->assign('id', 'ID');
   $smarty->assign('mitglieder', 'Mitglieder');
   $smarty->assign('beschreibung', 'Beschreibung');
   $smarty->assign('option', 'Option');
    $smarty->assign('anzahl', $count["Anzahl"]);
   $smarty->assign('table_data', $table_data);
    
      include("cms/layouts/admin/inc.header.tpl");
      $smarty->display('groups.tpl');
      include("cms/layouts/admin/inc.footer.tpl");
    break;
  }




Best regards
Alex
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 -> Help Wanted (commercial) 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