views:

36

answers:

1

Hello guys,

we've codeded this PHP-Script:

function price($id)
              {
                      $ergebnis = mysql_query("SELECT * FROM preiszuordnungen where id=$id");
                           while($row = mysql_fetch_object($ergebnis))
           { 
  //Wenn grundpreis dann färben
  if($row->typ=="grundpreis")
             {
      $gp="style=\"background-color: #FF22FF; color: #FFFFFF; padding: 5px;\"";
                }
              else
             {
               }

  //preisfomat umändern
           $preis="+ ".number_format($row->preis,2)." EUR";
            $GLOBALS["$id"] = $row->preis;





             //zeile ausgeben
          echo"<div $gp class=\"rechnung_bezeichnung\">$row->bezeichnung</div><div $gp                    class=\"rechnung_preis\">$preis</div><p style=\"clear: both;\">";
             }    
       }

our Problem is that we cant use the variable out of this function. In our Script we need the function like this:

$preis=price(101);

$preis=price(909);  
         ...

Now we want to sum the output of the function. variable $row->price

We're happy if someone could help us.

A: 

just add

return $row->preis;

to the end of the function.

Fosco
yeah, but we use per output one function and the function is ending if the echo is given out.
hoerf