inserting records via an array

admin

Administrator
Staff member
i am trying to populate data from an array into a table, but i cant figure out what i am doing wrong.

any help appreciated.

//mysql query
$sql = "SELECT charge_location.dept_code, charge_location.week,
Sum(charge_location.total_hrs_paid) AS sum_of_total_hrs_paid,
Sum(charge_location.hrs_non_chargeable) AS sum_of_hrs_non_chargeable
FROM charge_location
GROUP BY charge_location.dept_code, charge_location.week";

$result = mysql_query($sql);
$num_results = mysql_num_rows($result);

//populate the stats_table
for($i=0; $i<$num_results; $i++){
$row = mysql_fetch_array($result);
mysql_query("insert into stats_summary values(
($row[dept_code]),
($row[week]),
($row[sum_of_total_hrs_paid]),
($row[sum_of_hrs_non_chargeable]))
");
 
Back
Top