Postingan lainnya
Buku Ini Koding!
Baru!
Buku ini akan jadi teman perjalanan kamu belajar sampai dapat kerjaan di dunia programming!
Mengatasi fatal error crud menggunakan xml
kenapa ya kok saya run ada tulisan Warning: require(simplexml.class.php): failed to open stream: No such file or directory in C:\xampp\htdocs\crudxml\view.php on line 2
Fatal error: require(): Failed opening required 'simplexml.class.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\crudxml\view.php on line 2
<?php
require('simplexml.class.php');
if($_GET['act']=='hapus'){
$product = simplexml_load_file('product.xml');
$id = $_GET['id'];
$index = 0;
$i= 0;
foreach($product->product as $produk){
if($produk->id_produk == $id){
$index = $i;
break;
}
$i++;
}
unset($product->product[$index]);
file_put_contents('product.xml',$product->asXml());
}
$product = simplexml_load_file('product.xml');
$json = json_encode($product);
$array = json_decode($json,TRUE);
$jumlah = count($array);
$no=1;
echo"<a href='add.php'> <button>add</button> </a> <br><br>";
echo "<table border=0 width=100% style='padding:15px; border:1px solid #000;'> ";
echo "<tr bgcolor='#ccc'> <td>No</td> <td>Nama</td> <td>Harga</td> <td>Edit</td> <td>Hapus</td></tr> ";
foreach($product->product as $produk ){
if(($no%2)==0){
$warna="#ccc";
}else{
$warna="#fff";
}
echo "<tr bgcolor='$warna'><td>".$no."</td>";
echo "<td>".$produk->name."</td>";
echo "<td>".$produk->price."</td>";
echo "<td><a href='edit.php?id=".$produk->id_produk."'> <button>Edit</button></a></td>";
echo "<td><a href='index.php?act=hapus&id=".$produk->id_produk."'><button>Delete</button></a></td></tr>";
$no++;
}
echo" </table>";
?>
mohon solusinya. full link code saya ambil dari sini https://topidesta.wordpress.com/2016/04/29/crud-php-dan-xml-2-0/
Belum ada Jawaban. Jadi yang pertama Jawaban
Login untuk ikut Jawaban