Hello everybody! My problem is as follows: I am using an xml file with products info. Here it is - example.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<products>
<item>
<name>Flat Screen Television SONY KDL-4500WEED</name>
<image>http://img.zap.co.il/pics/2/7/9/2/37682972c.gif</image>
<description>This is our newest TV set from the SONY Comp. and we hope you buy it mothefuckerzzzz....zasdhaskjdhkahdca a dsah dha adlasldoao al ladjjada</description>
<left>17</left>
</item>
<item>
<name>Aiwa ozvuchitelna sistema</name>
<image>http://crev.vo.llnwd.net/o42/audioreview/images/products/product_119021.jpg</image>
<description>This is our newest TV set from the Aiwa Comp. and we hope you buy it mothefuckerzzzz....zasdhaskjdhkahdca a dsah dha adlasldoao al ladjjada</description>
<left>12</left>
</item>
<item>
<name>Blu-Ray DVD Player Panasonic</name>
<image>http://news.cnet.com/i/bto/20070725/BD-UP5000_overhead.jpg</image>
<description>This is our newest TV set from the Aiwa Comp. and we hope you buy it mothefuckerzzzz....zasdhaskjdhkahdca a dsah dha adlasldoao al ladjjada</description>
<left>33</left>
</item>
<item>
<name>DURO na SHISH...</name>
<image>http://media.otkrovenia.com/profiles/DureFF.jpg</image>
<description>This is our newest TV set from the Aiwa Comp. and we hope you buy it mothefuckerzzzz....zasdhaskjdhkahdca a dsah dha adlasldoao al ladjjada</description>
<left>18</left>
</item>
</products>
The idea is that a User can reserve numbers of the products by a php page, which will automatically tell him how many are left and change the values of the xml file of the certain products. Here is my php page - metro.php:
[php]<?php
$products = simplexml_load_file(“example.xml”);
$max_per_row = 2;
$item_count = 0;
echo ‘
Name: ’ , 'Description: ', $item->description , ' Left: | ', PHP_EOL;
And here is the PHP page for the action of the form. This is metro2.php:
[php]<?php
$products = simplexml_load_file(“example.xml”);
$fname = $_POST[‘fname’];
$left = $_POST[‘left’];
$new_left = $left - 1;
echo 'You want to reserve ', $fname, ‘.
’;
echo 'There are now only ‘, $new_left, ’ of this product.’;
$products->item->left = $new_left;
$products->asXML(“example.xml”);
?>[/php]
The problem is as follows. If we assume that I have 33 Aiwas and 17 SONYs, if I hit Reserve! for an Aiwa it gives me on metro2.php that 32 Aiwas, remain, but CHANGES THE VALUE of the LEFT ITEMS for the SONY, so when I reload the page metro.php it gives me that I have 33 Aiwas and 32 SONYs… It clearly does not change the value of the correct child of the products… Where is my mistake. I guest somewhere in page metro2.php… But i donno what to do… Please help Thanks in advance!