I am trying to create an array dynamically: here is the scenario.
instead of the line if ($row["dept"]== "cs") I would like to create an array that would use ' as an index. For example, I have a list that has 'CS', 'math', eng, sci etc.
What I want is to have an array that looks like this:
-------------------------------------
Cs | math | eng|
------------------------------------
and the value in array should be the number of times 'i' occurs in the list.
Code:
<?
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo("<tr>\n <td>".$row["fac_name"]. "</td>");
echo("<td>" .$row["dept"] ."</td>");
if ($row["dept"]== "cs") {
$numcs = $numcs + 1;
}
instead of the line if ($row["dept"]== "cs") I would like to create an array that would use ' as an index. For example, I have a list that has 'CS', 'math', eng, sci etc.
What I want is to have an array that looks like this:
-------------------------------------
Cs | math | eng|
------------------------------------
and the value in array should be the number of times 'i' occurs in the list.