"; echo "ID Navn Måltider Indkøb status"; foreach($members as $member) { $sum+=$member[3]; $meals+=$member[2]; } $price=$sum/$meals; foreach($members as $member) { echo ""; echo "\t".$member[0].""; echo "\t".$member[1].""; echo "\t".$member[2].""; echo "\t".$member[3].""; echo "\t"; printf("%.2f",($member[3]-($member[2]*$price))); echo ""; echo ""; } echo ""; echo "Pris pr. måltid: "; printf("%.2f",$price); } function readDatabaseloglines($password) { //returns list of students (id,name,meals,shopping) // $link = mysql_connect("mydb1.surf-town.net:3306", "buepe_frkstbr", $password) $link = mysql_connect("localhost:3306", "buepe_frkstbr", $password) or die("Could not connect to database"); mysql_select_db("buepe_huggefrokost") or die("Could not select database"); // $res = mysql_query("SELECT * FROM loglines order by id DESC LIMIT 0,60") $res = mysql_query("SELECT l.id, l.date, m.name, l.meals, l.shopping, l.action FROM loglines AS l LEFT JOIN members AS m on l.member=m.id order by l.date DESC, l.id DESC LIMIT 0,60") or die("!Could not execute query"); $i=0; while ($row = mysql_fetch_array($res)) { $rows[$i]=$row; $i++; } mysql_close(); return $rows; } function printloglines($rows){ echo ""; echo ""; # foreach($members as $member) { # $sum+=$member[3]; # $meals+=$member[2]; # } # $price=$sum/$meals; if (count($rows) < 1) { return; } foreach($rows as $r) { echo ""; echo "\t"; echo "\t"; echo "\t"; echo "\t"; echo "\t"; echo "\t"; # echo "\t"; echo ""; } echo "
logid date name meals shopping actiontext
".$r[0]."".$r[1]."".$r[2]."".$r[3]."".$r[4]."".$r[5].""; printf("%.2f",($member[3]-($member[2]*$price))); echo "
"; # echo "Pris pr. maaltid: "; printf("%.2f",$price); } ?> HüggeFrokostKlubben(TM)

HüggeFrokostKlubben(TM)

[shopping list] [admin page]