lilyyan
asked on
could some expert here explain the meaning of these code?
Hello:
could some expert here explain the meaning of these code? the more detail , the better
thank you so much for your reply!
The DB table for the php code
PROJTIME LOCATIONS LIMIT
Fall 2009 city A 5
Full year city A 5
Summer 2009 city A 5
could some expert here explain the meaning of these code? the more detail , the better
thank you so much for your reply!
The DB table for the php code
PROJTIME LOCATIONS LIMIT
Fall 2009 city A 5
Full year city A 5
Summer 2009 city A 5
<?php
include "dbConn.php";
$SQL = "SELECT * FROM ProjectGroups";
$rslt = mssql_query($SQL);
$i = 0;
while ($rw = mssql_fetch_assoc($rslt))
{
$projGroup[$i][0] = array($rw['PROJTIME']);
$projGroup[$i][1] = explode("XX", $rw['LOCATIONS']);
$projGroup[$i][2] = array($rw['LIMIT']);
$i++;
}
$i = 0;
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
if print_r($projGroup[1]);
Array (
[0] => Array ( [0] => Full Year )
[1] => Array ( [0] => city A)
[2] => Array ( [0] => 5 )
)
Array (
[0] => Array ( [0] => Full Year )
[1] => Array ( [0] => city A)
[2] => Array ( [0] => 5 )
)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
what is the third array?
can it be simplyfied? it's really confused me.
can it be simplyfied? it's really confused me.
ASKER
and what this means: projGroup[$i][1] = explode("XX", $rw['LOCATIONS']);
The third array is the actual value of the field so it goes like this:
$projGroup[recordnum][fiel d][value]
It could be simplified, assumming you only have one location, one time and one limit per each record in the database.
I would do something like this:
$projGroup[recordnum][fiel
It could be simplified, assumming you only have one location, one time and one limit per each record in the database.
I would do something like this:
while ($rw = mssql_fetch_assoc($rslt))
{
$projGroup[] = array("PROJTIME" => $rw['PROJTime'],
"LOCATIONS" => $rw['LOCATIONS'],
"LIMIT" => $rw['LIMIT']);
}
#get values like this:
foreach($projGroup as $key => $val) {
echo $key . ": " . $val . '<br />';
}
#or to get a specific field of a record:
$recnum = 1;
echo $projGroup[$recnum]["LOCATIONS"];
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
also what this means: projGroup[$i][1] = explode("XX", $rw['LOCATIONS']);
in my origional posted code
in my origional posted code
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Array (
[0] => Array ( [0] => Fall 2009 )
[1] => Array ( [0] => city A )
[2] => Array ( [0] => 5 )
)
could you please draw a matrix for me as i'm stll confused