firekiller15
asked on
How to add some column with | delimiter
PHP
Hi experts,
I have this program where i called the data from database.
The datafield i need to look for is absent and only absent will print out on the screen
In this database i need to retrieved data that with condition 1 to 7 (as day)
I have 3 value that i put it in an array e.g: $student = array(18,22,34) where i retrieved from database
I should have output of |||||||| if the student is not absent from day 1 to 7
But my problem now is say : studentID 18 only absent once on tuesday is will only print the string as below
absent|
and not
|absent||||||
below is my code
I need to find When a student is absent and the fieldname is ABSENT
I have 3 value that i put it in an array e.g: $student = array(18,22,34) where i retrieved from database
i called this array as ID's
since one week have 7 days so i create an array as array(1,2,3,4,5,6,7)
i do as follow
function ABSENT()
{
$DAY= array(1,2,3,4,5,6,7);
foreach($this->Getstudent as $student)
{
for ($j=0; $j<sizeof($IndexOrder);$j+ +)
{
$query = "SELECT ABSENT
FROM $ABSENTTABLE
WHERE STUDENT = \"$student\" AND INDEXORDER = $DAY[$j]";
$result = mysql_query($query);
while($row = mysql_fetch_array($result) )
{
$this->GetABSENT .= ''.$row['ABSENT'].'|';
}
}
}
mysql_close($dbLink);
}
THE CURRENT RESULT I GET IS EXAMPLE 22 ABSENT 2 DAYS ON MONDAY AND FRIDAY IT ONLYT PRINT OUT
ABSENT|ABSENT|
AND NOT
ABSENT||||ABSENT|||
how to solve this
Hi experts,
I have this program where i called the data from database.
The datafield i need to look for is absent and only absent will print out on the screen
In this database i need to retrieved data that with condition 1 to 7 (as day)
I have 3 value that i put it in an array e.g: $student = array(18,22,34) where i retrieved from database
I should have output of |||||||| if the student is not absent from day 1 to 7
But my problem now is say : studentID 18 only absent once on tuesday is will only print the string as below
absent|
and not
|absent||||||
below is my code
I need to find When a student is absent and the fieldname is ABSENT
I have 3 value that i put it in an array e.g: $student = array(18,22,34) where i retrieved from database
i called this array as ID's
since one week have 7 days so i create an array as array(1,2,3,4,5,6,7)
i do as follow
function ABSENT()
{
$DAY= array(1,2,3,4,5,6,7);
foreach($this->Getstudent as $student)
{
for ($j=0; $j<sizeof($IndexOrder);$j+
{
$query = "SELECT ABSENT
FROM $ABSENTTABLE
WHERE STUDENT = \"$student\" AND INDEXORDER = $DAY[$j]";
$result = mysql_query($query);
while($row = mysql_fetch_array($result)
{
$this->GetABSENT .= ''.$row['ABSENT'].'|';
}
}
}
mysql_close($dbLink);
}
THE CURRENT RESULT I GET IS EXAMPLE 22 ABSENT 2 DAYS ON MONDAY AND FRIDAY IT ONLYT PRINT OUT
ABSENT|ABSENT|
AND NOT
ABSENT||||ABSENT|||
how to solve this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Exactly.
You may actually want to fix line 11 though (since it'll loop from 0 to 6, you need to bump it up one to replace the 1..7 array):
You may actually want to fix line 11 though (since it'll loop from 0 to 6, you need to bump it up one to replace the 1..7 array):
WHERE STUDENT = \"$student\" AND INDEXORDER = ".($j + 1);
ASKER