Jump to content

Sitemap Generat Dinamic In Php


Recommended Posts

Marius Mailat prezinta o solutie de generare a unui sitemap in PHP. In exemplu ne este dat un site cu peste 200.000 de pagini si care va avea in jur de 40 de sitemap-uri.

Cum se face generarea ? Cu codul de mai jos:


//include baza de date



$mainPages = array(




//declara header si insceput sitemap

header ('Content-type: text/xml');

echo '<?xml version="1.0" encoding="ISO-8859-1" ?>';

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

for($i=0; $i<count($mainPages); $i++){

echo '<url>

<loc>'. $mainPages[$i] .'</loc>





//genereaza categoriile

$map_result = mysql_query("SELECT id FROM categorii");

while ($map_row = mysql_fetch_array($map_result)) {

$category = "http://www.domeniu.ro/categorie/" . $map_row['id'] . "/";

echo "


<loc>". $category ."</loc>





//genereaza elementele

$map_result = mysql_query("SELECT id FROM articole WHERE aprobat = 1??€

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.