How to save data on MySQL from PHP script?
I don't get errors or anything but it doesn't save in my db?
Please help.
<?php>
if(isset($_POST[save]))
{
//student,grade,section,subject
$ids=$_POST['id'];
$grades=$_POST['fg'];
$secs=$_POST['secs'];
$subs=$_POST['subs'];
$yirs=$g_year['acad_id'];
debug($_POST);
if(isset($_POST['save']))
{
unset($_POST['save']);
$i = count($_POST['id']); $x = 0;
for($x=0; $x <$i;$x++){
foreach($_POST as $data =>$d){
echo $data.'-'.$d[$x].'<br/>';
$num_entry=count($d);
$insert="INSERT INTO tbl_firstgrading {$data} VALUES (";
for($i=0;$i<$num_entry;$i++){
if($i!=$num_entry){
$insert.="$d,";
}
else
{
$result=mysql_query($insert)or die(mysql_error());
}
}
//SQL statement here (example): insert into table name (value ng $data) values( value ng $d[$x]) —
}}}}
?> <?php function debug($arr){ echo "
";
print_r($arr);
echo "
"; } ?>