I am having problems with some code so I am echoing it out to test all the variables.
I am confused why within an array I am getting information repeating itself
Before I go any further with the code I need to sort this out, can anyone help
the following code
$today = date('2005-03-30');
//$today = date('Y-m-d');
// set conces ref
$query="SELECT ConcesRef FROM `tblDateLog` WHERE `FirstRemind` = '$today'";
$result2 = mysql_query($query)
or die(mysql_error());
while ($row2 = mysql_fetch_array($result2))
$ConcesRef[] = $row2["ConcesRef"];
print_r($ConcesRef); echo'<br>';
foreach ($ConcesRef as $ref)
{
//find latest datelog ref
$query = "SELECT DateLogId FROM tblDateLog WHERE ConcesRef = '".$ref."' ORDER BY EndDate DESC LIMIT 1";
$result1 = mysql_query($query)
or die(mysql_error());
$row1 = mysql_fetch_array($result1);
$DateLogId = $row1["DateLogId"];
echo $DateLogId; echo'<br>';
//find user and client information for the date log
$query = "SELECT ClientId FROM tblClient, tblSection, tblDateLog
WHERE tblClient.ConcesRef = tblSection.ConcesRef AND tblDateLog.DateLogId = $DateLogId AND tblClient.ConcesRef = '".$ref."'";
$result3 = mysql_query($query) or die(mysql_error());
while($row3 = mysql_fetch_array($result3))
$ClientId[] = $row3["ClientId"];
$query = "SELECT CoName FROM tblClient, tblSection, tblDateLog
WHERE tblClient.ConcesRef = tblSection.ConcesRef AND tblDateLog.DateLogId = $DateLogId AND tblClient.ConcesRef = '".$ref."'";
$result4 = mysql_query($query) or die(mysql_error());
while($row4 = mysql_fetch_array($result4))
$ClientName[] = $row4["CoName"];
$query = "SELECT SectionId FROM tblSection, tblClient, tblDateLog
WHERE tblClient.ConcesRef = tblSection.ConcesRef AND tblDateLog.DateLogId = $DateLogId AND tblClient.ConcesRef = '".$ref."'";
$result5 = mysql_query($query) or die(mysql_error());
while($row5 = mysql_fetch_array($result5))
$SectionId[] = $row5["SectionId"];
$query = "SELECT SectionName FROM tblSection, tblClient, tblDateLog
WHERE tblClient.ConcesRef = tblSection.ConcesRef AND tblDateLog.DateLogId = $DateLogId AND tblClient.ConcesRef = '".$ref."'";
$result6 = mysql_query($query) or die(mysql_error());
while($row6 = mysql_fetch_array($result6))
$SectionName[] = $row6["SectionName"];
echo 'Client Id = '; print_r($ClientId); echo'<br>';
echo 'Section Id = '; print_r($SectionId); echo'<br>';
echo 'Client Name = '; print_r($ClientName); echo'<br>';
echo 'Section Name = '; print_r($SectionName); echo'<br>';
}// close foreach
gives this output
Array ( [0] => 2 )
70
Client Id = Array ( [0] => 354 [1] => 410 [2] => 354 [3] => 410 [4] => 354 [5] => 410 [6] => 354 [7] => 410 )
Section Id = Array ( [0] => 135 [1] => 136 [2] => 224 [3] => 225 [4] => 135 [5] => 136 [6] => 224 [7] => 225 )
Client Name = Array ( [0] => Rubber Soles [1] => yellow submarine ltd [2] => Rubber Soles [3] => yellow submarine ltd [4] => Rubber Soles [5] => yellow submarine ltd [6] => Rubber Soles [7] => yellow submarine ltd )
Section Name = Array ( [0] => london business park [1] => Ticknall Road Office [2] => Melbourne Road [3] => ashby business park [4] => london business park [5] => Ticknall Road Office [6] => Melbourne Road [7] => ashby business park )
Can anyone tell me why this is happening
thanks