Skip to main content
Create  dynamic sitemap  from MySQL database with php  --
-- Database: `test`
--

-- --------------------------------------------------------

--
-- Table structure for table `page`
--

CREATE TABLE IF NOT EXISTS `page` (
  `page_id` int(11) NOT NULL,
  `page_title` text NOT NULL,
  `page_url` text NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `page`
--

INSERT INTO `page` (`page_id`, `page_title`, `page_url`) VALUES
(1, 'JSON - Dynamic Dependent Dropdown List using Jquery and Ajax', 'json-dynamic-dependent-dropdown-list-using-jquery-and-ajax'),
(2, 'Live Table Data Edit Delete using Tabledit Plugin in PHP', 'live-table-data-edit-delete-using-tabledit-plugin-in-php'),
(3, 'Create Treeview with Bootstrap Treeview Ajax JQuery in PHP\r\n', 'create-treeview-with-bootstrap-treeview-ajax-jquery-in-php'),
(4, 'Bootstrap Multiselect Dropdown with Checkboxes using Jquery in PHP\r\n', 'bootstrap-multiselect-dropdown-with-checkboxes-using-jquery-in-php'),
(5, 'Facebook Style Popup Notification using PHP Ajax Bootstrap\r\n', 'facebook-style-popup-notification-using-php-ajax-bootstrap'),
(6, 'Modal with Dynamic Previous & Next Data Button by Ajax PHP\r\n', 'modal-with-dynamic-previous-next-data-button-by-ajax-php'),
(7, 'How to Use Bootstrap Select Plugin with Ajax Jquery PHP\r\n', 'how-to-use-bootstrap-select-plugin-with-ajax-jquery-php'),
(8, 'How to Load CSV File data into HTML Table Using AJAX jQuery\r\n', 'how-to-load-csv-file-data-into-html-table-using-ajax-jquery'),
(9, 'Autocomplete Textbox using Typeahead with Ajax PHP Bootstrap\r\n', 'autocomplete-textbox-using-typeahead-with-ajax-php-bootstrap'),
(10, 'Export Data to Excel in Codeigniter using PHPExcel\r\n', 'export-data-to-excel-in-codeigniter-using-phpexcel'); 

php  code

<?php
//sitemap.php
$connect = mysqli_connect("localhost", "root", "", "test");

$query = "SELECT page_url FROM page";

$result = mysqli_query($connect, $query);

$base_url = "http://localhost/app/test/sitemap/";

header("Content-Type: application/xml; charset=utf-8");

echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;

echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL;

while($row = mysqli_fetch_array($result))
{
 echo '<url>' . PHP_EOL;
 echo '<loc>'.$base_url. $row["page_url"] .'/</loc>' . PHP_EOL;
 echo '<changefreq>daily</changefreq>' . PHP_EOL;
 echo '</url>' . PHP_EOL;
}

echo '</urlset>' . PHP_EOL;

?>
output

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>
http://localhost/app/test/sitemap/json-dynamic-dependent-dropdown-list-using-jquery-and-ajax/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/live-table-data-edit-delete-using-tabledit-plugin-in-php/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/create-treeview-with-bootstrap-treeview-ajax-jquery-in-php/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/bootstrap-multiselect-dropdown-with-checkboxes-using-jquery-in-php/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/facebook-style-popup-notification-using-php-ajax-bootstrap/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/modal-with-dynamic-previous-next-data-button-by-ajax-php/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/how-to-use-bootstrap-select-plugin-with-ajax-jquery-php/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/how-to-load-csv-file-data-into-html-table-using-ajax-jquery/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/autocomplete-textbox-using-typeahead-with-ajax-php-bootstrap/
</loc>
<changefreq>daily</changefreq>
</url>
<url>
<loc>
http://localhost/app/test/sitemap/export-data-to-excel-in-codeigniter-using-phpexcel/
</loc>
<changefreq>daily</changefreq>
</url>

</urlset>

Comments

Popular posts from this blog

Minimum and maximum number with - and + 500 in Mysql and Sql query and Find out table scheema of our database in Mysql and sql query and Find out all table name of our database in Mysql and sql query and Find out current date and time in mysql and sql help of sql query

Minimum and maximum number with - and + 500 in Mysql and Sql query:- syntax:-  SELECT MIN(Used)-500 , max(Used)+500 FROM audit Find out current date and time in mysql and sql help of sql query:- syntax:- SELECT now() Find out database name in Mysql and sql query:- syntax:-  SELECT DATABASE(); Find out all table name of our database in Mysql and sql query:- syntax:- SHOW TABLES; Find out   table scheema   of our database in Mysql and sql query:- syntax:- DESCRIBE <table name>;

Php prime number program with use of class

Php prime number  program with use of class <?php class find_p_number { # Function to check single number is Prime or not static function isPrime ( $ number ) { # Start temporary number from 2 (1 is not a prime number) $ i = 2 ; # 1 is not a prime number if ( $ number == 1 ) return false ; # 2 is the only even prime number if ( $ number == 2 ) return true ; # Check numbers other than 1 and 2 while ( $ i <= sqrt ( $ number ) ) { if ( $ number % $ i == 0 ) return false ;   $ i ++ ; } # If the execution has come to this point, means it is a prime Number :) return true ; } # Function to check Prime Numbers between two given numbers static function betweenTwoNumbers ( $ num1 , $ num2 ) { $ prime_numbers = array ( ) ; # Check Prime Numbers between two given numbers for ( $ num1 ; $ num1 < $ num2 ; $ num1 +...