Code: Select all
$mode=$_REQUESTї'mode'];
if($mode=='insert'){
if(isset($_POSTї'submit'])){
if((strlen($_POSTї'title'])>0) AND (strlen($_POSTї'creator'])>0)){
$today = date("d-m-Y G:i:s");
$creator=$_REQUESTї'creator'];
$title=$_REQUESTї'title'];
$audience=$_REQUESTї'audience'];
$description=$_REQUESTї'description'];
$contents=$_REQUESTї'contents'];
$contents=ereg_replace("\r\n","їnl]", $contents);
$respsite=$_REQUESTї'respsite'];
$url=$_REQUESTї'url'];
$location=$_REQUESTї'location'];
$created=$today;
$modified=$today;
$keywords=$_REQUESTї'keywords'];
//$document=domxml_xmltree($f);
if (!$doc = domxml_open_file("lessons.xml")) {
echo "The file was found empty.<br>Creating new tree!";
$doc = domxml_new_doc('1.0');
$root = $doc->create_element('root');
$root = $doc->append_child($root);
//Use only if lessons.xml is empty
}
$root = $doc->document_element();
$occ = $doc->create_element('Library');
$occ = $root->append_child($occ);
$child = $doc->create_element('Creator'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($creator); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Title'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($title); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Description'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($description); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Description.audience'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($audience); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Description.contents'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($contents); //fieldvalue
$value = $child->append_child($value);
while(isset($keywordsї$i])){
//echo $keywordsї$i];
$child = $doc->create_element('Description.keywords'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($keywordsї$i++]); //fieldvalue
$value = $child->append_child($value);
}
$child = $doc->create_element('Description.respsite'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($respsite); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Description.url'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($url); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Date.Created'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($created); //fieldvalue
$value = $child->append_child($value);
$child = $doc->create_element('Date.Modified'); //fieldname
$child = $occ->append_child($child);
$value = $doc->create_text_node($modified); //fieldvalue
$value = $child->append_child($value);
// get completed xml document
$xml_string = $doc->dump_mem(true);
$f=fopen("lessons.xml","a+");
fwrite($f,$xml_string);
fclose($f);
}
}
}
}and i can not find the logic how can i increase the primary id count (or whatever) in order to select each record separately?
I believe then it is quite easy to make modifications to existing records...
Thanks for your help in advance!