Hi,
I am tiring to update data into table_course
<?php
// update the ite_aps data into sgc table
require_once('../../includes/common.php');
$m = array();
$result = mysql_query("SELECT * from sgc where year = '2008'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
//echo $row['nric'];
$res =mysql_query("select COURSE_TITLE_LONG, CRSE_GRADE_OFF, UNT_EARNED, nric from ite where nric = '".$row['nric']."' AND STRM = '2008'")or die(mysql_error());
$norows=mysql_num_rows($res);
echo $norows."<br>";
$update = 'UPDATE sgc SET meta_ite = ';
while($rows = mysql_fetch_array($res))
{
for($i=0;$i<$norows;$i++){
$data = array("course" => "'".$rows['COURSE_TITLE_LONG']."'" , "Grade" => "'".$rows['CRSE_GRADE_OFF']. "'" , "Unit" => "'".$rows['UNT_EARNED']."'");
$m = serialize($data);
}
print $m."<br>";
$update .= '"'.mysql_real_escape_string($m).'"';
}
$update .= 'WHERE nric = "'.$row['nric'].'" AND year = "2008"' ;
print $update."<br>";
// mysql_query($update);
}
?>
I got below output for above coding
a:3:{s:6:"course";s:24:"'Personal Effectiveness'";s:5:"Grade";s:3:"'S'";s:4:"Unit";s:3:"'3'";}
a:3:{s:6:"course";s:16:"'Basic Numeracy'";s:5:"Grade";s:3:"'U'";s:4:"Unit";s:3:"'2'";}
a:3:{s:6:"course";s:23:"'Piping & Valve System'";s:5:"Grade";s:3:"'D'";s:4:"Unit";s:3:"'6'";}
a:3:{s:6:"course";s:24:"'Mechanical Fabrication'";s:5:"Grade";s:3:"'F'";s:4:"Unit";s:3:"'6'";}
the output format is: array(course,grade,unit)array(course,grade,unit) - in serialize
But, i want the output in this format: array(array(course,grade,unit),array(course,grade,unit)........) -in serialize
for example: a:5:{a:3:{s:6:"course";s:24:"'Personal Effectiveness'";s:5:"Grade";s:3:"'S'";s:4:"Unit";s:3:"'3'";}'
a:3:{s:6:"course";s:16:"'Basic Numeracy'";s:5:"Grade";s:3:"'U'";s:4:"Unit";s:3:"'2'";}.......}
Please any one help me, because i am new for php mysql.
Thanks.
Originally asked by: apssiva on Stack Overflow


Answers