<?php include('variables/variables.php'); ?>
<div id="header">
<?php
include ('includes/db-zelf.php');
// define your database connection credentials
mysql_connect( $db_host, $db_user, $db_password ) or die(mysql_error());
mysql_select_db( $db_database ) or die(mysql_error());
/* KUBAGES */
$Luchtvr = mysql_query("SELECT * FROM Luchtvrachtpalletten WHERE ID='1'") or die(mysql_error());
while($Luchtvra = mysql_fetch_array( $Luchtvr ))
{
$kuubid = $Luchtvra['ID'];
$kuubvol = $Luchtvra['Volume'];
$kuub = round(($kuubvol / 167)*2,2);
/* EINDE KUBAGES */
}
/* SELECT ONLY THE ACTIVE SHIPMENTS */
$Active = mysql_query("SELECT ID FROM Zendingen WHERE Actief='1'")
or die(mysql_error());
$ros = mysql_num_rows($Active);
$i=0;
while($i<$ros)
{
$lol = mysql_fetch_array( $Active );
$testz = $lol['ID'];
/* END SELECT */
/* BEGIN CODE TO GET DATA FROM SHIPMENTS */
$zendingheader = mysql_query("SELECT Bestemming, Datum FROM Zendingen WHERE ID = $testz order by Datum ASC LIMIT 0,30") or die(mysql_error());
$zendinghead = mysql_fetch_array( $zendingheader );
$probeerselbe = $zendinghead['Bestemming'];
$probeerselda = $zendinghead['Datum'];
$zending_da = date("d-m-Y", strtotime($probeerselda));
echo "<br />";
echo "Zending ";
echo $probeerselbe;
echo " voor datum ";
echo $zending_da;
echo " heeft nog ";
echo $kuub;
echo " kuub over en bevat ";
/* END DATAGET*/
/* BEGIN BIRD COUNT */
$zendingheader1 = mysql_query("SELECT s.Aantal_Manden, m.Aantal_Duiven FROM Shipments AS s JOIN Zendingen AS z ON s.Zending_ID = z.ID JOIN Manden AS m ON s.Mand_ID = m.ID WHERE z.ID = $testz order by s.Aantal_Manden, m.Aantal_Duiven ASC LIMIT 0,30") or die(mysql_error());
$ros2 = mysql_num_rows($zendingheader1);
$y=0;
while($y<$ros2)
{
$zendinghead1 = mysql_fetch_array( $zendingheader1 );
/*TOTAL AMOUNT OF BIRDS IN SHIPMENT*/
$testarray1[] = ($zendinghead1['Aantal_Manden']*$zendinghead1['Aantal_Duiven']);
$y++;
}
$testtot1 = array_sum($testarray1);
/* END BIRD COUNT */
echo $testtot1;
echo " duiven in totaal.";
$i++;
}
?>
</div> <!-- end #header -->
So I want this loop to go fetch the amount of birds in a shipment. With 1 shipment, everything is okay. But as soon as I add another one it adds the first shipment to it.
What am I doing wrong in this loop?
EG: Shipment 1: 50 Birds / Shipment 2: 10 Birds
Bird count Shipment 1: 50 / Bird count shipment 2: 60. :(
Thx in advance