I have this following xml part
<Form>
<Team id="3041" name="Gefle" position="7" played="6" won="2" draw="3" lost="1" scored="10" against="9" points="9,00" form="D-W-D-W-D-L" />
<Team id="3051" name="Halmstad" position="13" played="6" won="1" draw="3" lost="2" scored="7" against="9" points="6,00" form="D-W-L-D-L-D" />
</Form>
I get the values like:
$form=array();
for ($i = 0; $i < sizeof($veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team); $i++) {
$form['id'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['id'];
$form['name'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['name'];
$form['position'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['position'];
$form['played'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['played'];
$form['won'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['won'];
$form['draw'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['draw'];
$form['lost'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['lost'];
$form['scored'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['scored'];
$form['against'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['against'];
$form['points'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['points'];
$form['form'][$i] = $veri->Sport->Country->Tournament->Season->Stage->Match->Form->Team[$i]['form'];
// echo $form['id'][$i] ."<br/>".$form['name'][$i] ."<br/>".$form['position'][$i]."<br/>".$form['played'][$i] ."<br/>".$form['won'][$i]."<br/>" .$form['draw'][$i]."<br/>".$form['lost'][$i]."<br/>".$form['scored'][$i] ."<br/>".$form['against'][$i] ."<br/>".$form['points'][$i] ."<br/>".$form['form'][$i]. "<hr/>";
}
no problem so far. But when I try insert these records in db like this:
$sorgu = mysql_query("SELECT * FROM takim WHERE id='$homeid'");
$etki = mysql_affected_rows();
if ($etki > 0) {
for ($i = 0; $i < sizeof($form['id']); $i++) {
if ($form['id'][$i] == $homeid) {
$takiminid = $i;
$takimid = $form['id'][$takiminid];
$takimisim = $form['isim'][$takiminid];
$takimpozisyon = $form['pozisyon'][$takiminid];
$takimplayed = $form['played'][$takiminid];
$takimwon = $form['won'][$takiminid];
$takimlost = $form['lost'][$takiminid];
$takimdraw = $form['draw'][$takiminid];
$takimscored = $form['scored'][$takiminid];
$takimagainst = $form['against'][$takiminid];
$takimpoints = $form['points'][$takiminid];
$takimform = $form['form'][$takiminid];
$sorgu = mysql_query("UPDATE takim SET isim='$takimisim', pozisyon='$takimpozisyon', oynanan='$takimplayed', kazan='$takimwon', beraber='$takimdraw', kaybet='$takimlost', scored='$takimscored', against='$takimagainst', points='$takimpoints', form='$takimform' WHERE id='$takimid'");
}
}
}
else {
for ($i = 0; $i < sizeof($form['id']); $i++) {
if ($form['id'][$i] == $homeid) {
$takiminid = $i;
$takimid = $form['id'][$takiminid];
$takimisim = $form['isim'][$takiminid];
$takimpozisyon = $form['pozisyon'][$takiminid];
$takimplayed = $form['played'][$takiminid];
$takimwon = $form['won'][$takiminid];
$takimlost = $form['lost'][$takiminid];
$takimdraw = $form['draw'][$takiminid];
$takimscored = $form['scored'][$takiminid];
$takimagainst = $form['against'][$takiminid];
$takimpoints = $form['points'][$takiminid];
$takimform = $form['form'][$takiminid];
$sorgu = mysql_query("INSERT INTO takim (id, isim, pozisyon, oynanan, kazan, beraber, kaybet, scored, against, points, form) VALUES ('$takimid', '$takimisim', '$takimpozisyon', '$takimplayed', '$takimwon', '$takimdraw', '$takimlost', '$takimscored', '$takimagainst', '$takimpoints', '$takimform')");
}
}
}
I get this error :
Notice: Undefined index: id in C:\xampp\htdocs\Demo\index.php on line 154
which is
for ($i = 0; $i < sizeof($form['id']); $i++) { in else part.
and doesn't insert values to db. What seems to be the problem?