Author Topic: What is wrong here ??  (Read 727 times)

0 Members and 1 Guest are viewing this topic.

Boggi

  • Guest
What is wrong here ??
on: Fri, 27. September 2002 - 09:56:55
i have try to write a loop and cant find the Problem
can you help me please ....

here a part of the template:

        <tmpl_loop name="myloop"> <!-- do the loop -->
<form method="post" action="updateLager.php">
            <tr onmouseover="setPointer(this, '#CCFFCC')" onmouseout="setPointer(this, '#DDDDDD')">
                <td bgcolor="#DDDDDD"> <INPUT type=hidden name="ArtikelNummerCh" value="<tmpl_var name="Artikel"> "><tmpl_var name="Artikel">
                <td bgcolor="#DDDDDD"> <tmpl_var name="Anzahl">
                <td bgcolor="#DDDDDD"> <tmpl_var name="Artikelbezeichnung">
                <td bgcolor="#DDDDDD"> <tmpl_var name="Verpackungsinhalt"> g
           <td bgcolor="#DDDDDD"> <INPUT type=hidden name="StandortCh" value="<tmpl_var name="ID"> "><tmpl_var name="Standort">

      <td bgcolor="#DDDDDD"> <input name="Anzahl" size=10 type="text">   
               <select name="Art">
               <option value="-1">Vermindern</option>
               <option value="1">Vermehren</option>
               <option value="0">Löschen</option>
               <option value="2">Umbuchen</option>
               </select>
            <input type="submit" value="OK"/>
          <select name="StandortChNew" style="vertical-align: middle">
      <tmpl_loop name="StandortCH_Loop">                
         <option value="<tmpl_var name="ID">"><tmpl_var name="Standort"></option>
      </tmpl_loop>
</select>


            </tr>
</form>    
        </tmpl_loop>



and now here a part from php script
the detais (for the inner loop)(i need this only one time, but ever in the outer loop):

   $detailsarr = array();
   $detailsarr1 = array();
   $row = mysql_fetch_array($r);
   $qe = sprintf("select ID,Standort from Standorte");
   $re = mysql_query($qe, $cnx);

   while($rowe = mysql_fetch_array($re, MYSQL_ASSOC))
   {
      //echo $rowe[ID];
      array_push($detailsarr, $rowe);
      //echo $detailsarr[0][ID];
   array_push($detailsarr1,array('StandortCH_Loop'=>$detailsarr));

   }   

and here the outer loop:

      $q = "select l.Artikel,l.Anzahl, a.Artikelbezeichnung,a.Verpackungsinhalt, s.Standort, s.ID  from Lager l, Artikel a, Standorte s where l.Standort=s.id AND l.Artikel=a.ID";
   }

   $tabledata = array();
   $r = mysql_query($q, $cnx);
   for ($i = 0; $i < mysql_numrows($r); $i++)
   {
      $row = mysql_fetch_array($r);
      
      
           array_push($row,$detailsarr1);
            
      //array('StandortCH_Loop'=>$detailsarr)
      //array_push($tabledata, $row);
   }
   array_push($tabledata, $row);   
   $tmpl -> setloop('myloop', $tabledata);

can you halp me ... i dont understan the problem, i can't find the problem :cry:

releasedj

  • Guest
What is wrong here ??
Reply #1 on: Fri, 27. September 2002 - 10:49:30
You just need a few adjustments to your php:

Code: [Select]

inner loop



$detailsarr = array;

$row = mysql_fetch_array$r;

$qe = sprintfselect ID,Standort from Standorte;

$re = mysql_query$qe, $cnx;



while$rowe = mysql_fetch_array$re, MYSQL_ASSOC



    array_push$detailsarr, $rowe;







and the outer loop



$tabledata = array;

$r = mysql_query$q, $cnx;

for $i = 0; $i mysql_numrows$r; $i++



    $row = mysql_fetch_array$r, MYSQL_ASSOC;

    $tabledata$i = $row;

    $tabledata$i'StandortCH_Loop' = $detailsarr;



$tmpl - setloop'myloop', $tabledata;



This should work.

Regards,

Kelvin

Boggi

  • Guest
What is wrong here ??
Reply #2 on: Fri, 27. September 2002 - 11:10:15
it runs ... big thx