hi fellows
I have a form that has four fields, when i submit I writes all the fields value to an XML file, its not writing but APPENDING so the new record comes to the end of file,
here is the code,
$joint = time();
$fname = "profiles/DB".".xml";
if($fp = fopen($fname,"a")) {
//fputs($fp,"<!xml version 1.0>\r\n");
fputs($fp,"\r\n\r\n<!-######## Profile for ".$POST['cmpname']." Starts here########-->\r\n\r\n");
fputs($fp,"<stdName>".$POST['cmpname']."</stdName>\r\n");
fputs($fp,"<class>".$POST['cmpclass']."</class>\r\n");
fputs($fp,"<rollno>".$POST['cmproll']."</rollno>\r\n");
fputs($fp,"<course>".$POST['cmpcourse']."</course>\r\n");
fputs($fp,"\r\n\r\n<!-######## Profile for ".$POST['cmpname']." ends here########-->\r\n\r\n");
echo "\n\nProfile for <b>". $_POST['cmpname']."</b> is created \r\n\r\n";
}
else
echo "sorry, file is not created";
fclose($fp);
this code is working perfect and every time a new record is apended to the end of file, now i want to search this file on conditional basis,
the fours fields are
1 - student name
2 - class
3 - roll no.
4 - course
i want to search and pick the data on the basis of COURSE tag in xml file, e.g for student WEBMASTER i have data in XML like
<name>WEBMASTER</name>
<class>C-MOD</class>
<rollno>12121</rollno>
<course>PHP, HTML</course>
now if some one writes PHP and HTML in the search form it should pick this record up and display, if someone writes PHP or HTML only then also this record must be picked and if someone writes PHP,ASP,JAVA, HTML then also this record is desired to be picked,,,, and if the search words match more than one students profile then it must pick all of them and display in organized form.
I am just stuck with this searching trick and not getting how to do it, please give me ideas how can i search XML file using php implementing the above logic.
thanks in advance