Hi,
I already posted another thread about how to write XML with PHP.
Well that worked, only if i write a new one it overwrites the old XML file.
I want to add the information in the same XML file only without overwriting it.
How to do that?
The part that writes it to xml:
The entire code:
-------------------------------------
I am a progammer.... no realy.
I already posted another thread about how to write XML with PHP.
Well that worked, only if i write a new one it overwrites the old XML file.
I want to add the information in the same XML file only without overwriting it.
How to do that?
The part that writes it to xml:
Code:
<?php
// TEST
$informatie = array();
$informatie [] = array(
'Auto' => $_POST['artikel'],
'Shortd' => $_POST['korte_omschrijving'],
'Longd' => $_POST['uitgebreide_omschrijving'],
'Prijs' => $_POST['prijs']);
$doc = new DOMDocument();
$doc->formatOutput = true;
$r = $doc->createElement( "Informatie" );
$doc->appendChild( $r );
foreach( $informatie as $info )
{
$b = $doc->createElement( "Auto" );
$auto = $doc->createElement( "Auto" );
$auto->appendChild(
$doc->createTextNode( $info['Auto'] )
);
$b->appendChild( $auto );
$shortd = $doc->createElement( "Shortd" );
$shortd->appendChild(
$doc->createTextNode( $info['Shortd'] )
);
$b->appendChild( $shortd );
$longd = $doc->createElement( "Longd" );
$longd->appendChild(
$doc->createTextNode( $info['Longd'] )
);
$b->appendChild( $longd );
$prijs = $doc->createElement( "Prijs" );
$prijs->appendChild(
$doc->createTextNode( $info['Prijs'] )
);
$b->appendChild( $prijs );
$r->appendChild( $b );
}
echo $doc->saveXML();
$doc->save("info.xml")
?>
The entire code:
Code:
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
ini_set('error_reporting', 8191);
ini_set('docref_root', '[URL unfurl="true"]http://www.php.net/');[/URL]
ini_set('date.timezone', 'Europe/Amsterdam');
//echo $_POST;
//includes
include_once '../../includes/db.inc.php';
include_once 'admin.inc.php';
//functies
check_login();
top_admin('prijzen', $pagina_titel);
open_db();
//Get the file out of the form that was sended
$uploadedfile = $_FILES['plaatje']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
//Creates new width and height for the picture
$newwidth=60;
$newheight=80;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$original_filename = "../../occasions/fotos_small/".$_FILES['plaatje']['name'];
$new_filename = trim( strtolower( $original_filename ), 'jpg' ) . 'png';
//preg_match('~/(:<png_file>.+\.png)$~', $new_filename, $matches);
//$naam_plaatje = str_ireplace('.jpg', '.png', $_FILES['plaatje']['name');
$array = explode('/', $new_filename);
$last = end($array);
$sql="INSERT INTO prijzen (Omschrijving, omschrijving1, omschrijving2, dagprijs, foto)
VALUES
('$_POST[artikel]', '$_POST[korte_omschrijving]', '$_POST[uitgebreide_omschrijving]', '$_POST[prijs]', '" . $last . "')";
//echo '<pre>' . print_r($matches, true) . '</pre>';
//echo $sql . "<br />" . "<br />";
mysql_query($sql);
//$filename = "../occasions/fotos_small/". $_FILES[plaatje][name];
imagepng($tmp,$new_filename,9);
//$filename2 = "../occasions/fotos_medium/". $_FILES[plaatje_m][name];
imagedestroy($src);
imagedestroy($tmp);
//if (isset($_FILES['plaatje'])){
// writetofolder('../occasions/fotos_small');
//}
//
//if (isset($_FILES['plaatje_m'])){
// writetofolder2('../occasions/fotos_medium');
//}
//function writetofolder($foldername){
// if (!is_file($_FILES['plaatje']['tmp_name'])) return false;
// $f = copy ($_FILES['plaatje']['tmp_name'], $foldername . '/'.$_FILES['plaatje']['name']);
// return $f;
//}
//function writetofolder2($foldername){
// if (!is_file($_FILES['plaatje_m']['tmp_name'])) return false;
// $f = copy ($_FILES['plaatje_m']['tmp_name'], $foldername . '/'.$_FILES['plaatje_m']['name']);
// return $f;
//}
echo '<table>';
echo '<tr>';
echo '<tr>';
echo '<td>';
echo "Auto:";
echo '</td>';
echo '<td>';
echo $_POST['artikel'];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo "Korte omschrijving:";
echo '</td>';
echo '<td>';
echo $_POST['korte_omschrijving'];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo "Uitgebreide omschrijving:";
echo '</td>';
echo '<td>';
echo $_POST['uitgebreide_omschrijving'];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo "Prijs:";
echo '</td>';
echo '<td>';
echo $_POST['prijs'];
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td>';
echo "Plaatje:";
echo '</td>';
echo '<td>';
echo $last;
echo '</td>';
echo '</tr>';
echo '</table>';
/*echo "Artikel:" ." " .$_POST['artikel'] . "<br />";
echo "Korte omschrijving:" ." " .$_POST['korte_omschrijving'] . "<br />";
echo "Uitgebreide omschrijving:" ." " .$_POST['uitgebreide_omschrijving'] . "<br />";
echo "Prijs:" ." " .$_POST['prijs'] . "<br />";
echo "Plaatje:" ." " .$last . "<br />";
echo "Plaatje groot:" ." " .$last2 . "<br />";*/
?>
<?php
// TEST
$informatie = array();
$informatie [] = array(
'Auto' => $_POST['artikel'],
'Shortd' => $_POST['korte_omschrijving'],
'Longd' => $_POST['uitgebreide_omschrijving'],
'Prijs' => $_POST['prijs']);
$doc = new DOMDocument();
$doc->formatOutput = true;
$r = $doc->createElement( "Informatie" );
$doc->appendChild( $r );
foreach( $informatie as $info )
{
$b = $doc->createElement( "Auto" );
$auto = $doc->createElement( "Auto" );
$auto->appendChild(
$doc->createTextNode( $info['Auto'] )
);
$b->appendChild( $auto );
$shortd = $doc->createElement( "Shortd" );
$shortd->appendChild(
$doc->createTextNode( $info['Shortd'] )
);
$b->appendChild( $shortd );
$longd = $doc->createElement( "Longd" );
$longd->appendChild(
$doc->createTextNode( $info['Longd'] )
);
$b->appendChild( $longd );
$prijs = $doc->createElement( "Prijs" );
$prijs->appendChild(
$doc->createTextNode( $info['Prijs'] )
);
$b->appendChild( $prijs );
$r->appendChild( $b );
}
echo $doc->saveXML();
$doc->save("info.xml")
?>
-------------------------------------
I am a progammer.... no realy.