السلام عليكم ورحمة الله وبركاته
إخواني حاولت حتى تعبت من عملية تحميل ملف xml إلى قاعدة البيانات باستخدام خاصية Dom وهي مفعلة من السيرفر.
أرجو النظر في الكود ومعرفة المشكلة:
$data = array();
function add_student($studentname,$studentid)
{
global $data;
$data[]=array('studentname'=>$studentname,'studentid'=>$studentid);
}
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
$x=0;
foreach ($rows as $row)
{
if ( !$first_row )
{
$studentname="";$studentid="";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind != null ) $index = $ind;
if ( $index == 1 ) $studentname = $cell->nodeValue;
if ( $index == 2 ) $studentid = $cell->nodeValue;
$index += 1;
}
add_student($studentname,$studentid);
}
$x++;
if ($x==2)
$first_row = false;
}
}
echo "<script language=javascript>alert('List has been added successfully.')</script>";
foreach($data as $row)
{
$query="insert into muath_marks (studentname,studentid) values ('".
$row['studentname']."','".
$row['studentid']."'')";
$result=mysql_query($query);وأشكر كل من يساعد إخوانه.
أخوكم: Muath2000