Skip to content

Instantly share code, notes, and snippets.

<?php
echo <<<__xml
<?xml version="1.0" encoding="UTF-8"?>
<me>Hello from {$_SERVER['PHP_SELF']}</me>
__xml;
?>
<!DOCTYPE html>
<html>
<head>
<title>AJAX pull XML Example</title>
<style>
textarea {
outline: none;
resize: none;
width: 400px;
<!DOCTYPE html>
<html>
<head>
<title>AJAX pull XML Example</title>
<style>
textarea {
outline: none;
resize: none;
width: 400px;
height: 400px;
<?php
$xml = new DOMDocument();
$xml->load('cv2.xml');
if (!$xml->schemaValidate('EuropassSchema.xsd')) {
echo libxml_display_errors();
}
else {
echo "Document is valid";
}
<?php
libxml_use_internal_errors(true);
$xml = new XMLReader;
$xml->open('cv2.xml');
$xml->setSchema('EuropassSchema.xsd');
while (@$xml->read()) {};
if (count(libxml_get_errors ())==0) {
<?php
libxml_use_internal_errors(true);
$xml = new XMLReader;
$xml->open('cv2.xml');
$xml->setSchema('EuropassSchema.xsd');
while (@$xml->read()) {};
if (count(libxml_get_errors ())==0) {
CREATE TABLE IF NOT EXISTS `category` (
`categoryID` INT NOT NULL AUTO_INCREMENT ,
`catName` VARCHAR(48) NOT NULL ,
`catParent` INT NOT NULL ,
PRIMARY KEY (`categoryID`) )
ENGINE = InnoDB;
CREATE TABLE IF NOT EXISTS `product` (
`productID` INT NOT NULL AUTO_INCREMENT ,
`prodName` VARCHAR(72) NOT NULL ,
INSERT INTO `category` (`categoryID`, `catName`, `catParent`) VALUES
(1, 'Kitchen and Home Appliances', 0),
(2, 'Computers and Electronics', 0),
(3, 'Sports and Outdoors', 0),
(4, 'Garden and Outdoors', 0),
(5, 'Irons', 1),
(6, 'Cameras', 2),
(7, 'Toasters', 1),
(8, 'Kettles', 1),
(9, 'Laptops', 2),
<?php
function returnTable ($con, $sql, $format, $imgwidth=200) {
$con->query('SET NAMES utf8');
$result = $con->query($sql);
$table = '<table>';
$table .= '<tr>';
foreach($format as $key=>$val) {
$table .= "<th>$val</th>";
<?php
function returnTable ($con, $sql, $format) {
$con->query('SET NAMES utf8');
$result = $con->query($sql);
$table = '<table>';
$table .= '<tr>';
foreach($format as $key=>$val) {
$table .= "<th>$val</th>";