Click here to Skip to main content
15,880,392 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number0527-Jun-17 5:10
Number0527-Jun-17 5:10 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Richard Deeming27-Jun-17 5:37
mveRichard Deeming27-Jun-17 5:37 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number0528-Jun-17 4:30
Number0528-Jun-17 4:30 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Richard Deeming28-Jun-17 7:46
mveRichard Deeming28-Jun-17 7:46 
GeneralRe: SQL: Split calendar week between a given two date time Pin
Number053-Jul-17 1:41
Number053-Jul-17 1:41 
QuestionBasic Entity Framework Question Pin
Kevin Marois21-Jun-17 7:54
professionalKevin Marois21-Jun-17 7:54 
AnswerRe: Basic Entity Framework Question Pin
mike1402125-Jun-17 21:24
mike1402125-Jun-17 21:24 
QuestionPDO Return Single Result, How To Return Different Record From 1 Column Multiple Rows Pin
Member 1326709919-Jun-17 1:21
Member 1326709919-Jun-17 1:21 
I am making a custom Sitemap from my database and stuck with following Issue

SQL Query:
SQL
SELECT term_id FROM wp_term_taxonomy WHERE taxonomy="product-cat" || taxonomy="product-brand"

Query Output

term_id
365
369
370


It returns all term_id from my database through which I gather category slugs from another table to make sitemap URLs. Below is the code and it works fine as you can see in (sitemap output), but unfortunately I am unable to extract next row term_id & it shows always same term_id to me as a result 'Same URL'

My Sitemap Output
PHP
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>
http://domain.com/search-page/?product-cat=mobiles-tablets	365
</loc>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>
http://domain.com/search-page/?product-cat=mobiles-tablets	365
</loc>
<changefreq>always</changefreq>
<priority>1.0</priority>
</url>
</urlset>


CODE
PHP
<?php
header("Content-type: text/xml");
$i=0;
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= "\n".'<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
  $db = new PDO('mysql:host=xxx;dbname=xxx', 'xx', 'xxx');
  $stmt[$i] = $db->query('SELECT count(*) FROM wp_term_taxonomy WHERE taxonomy="product-cat" || taxonomy="product-brand"');
  $rowcount = $stmt[$i]->fetchColumn();
      for ($i=0; $i<2; $i++)
      {
        $sth[$i] = $db->query('SELECT term_id FROM wp_term_taxonomy WHERE taxonomy="product-cat" || taxonomy="product-brand"');
        $t_id[$i] = $sth[$i]->fetchColumn();
        $stmt[$i] = $db->query('SELECT taxonomy FROM wp_term_taxonomy WHERE term_id = '.$t_id[$i].'');
        $t_taxonomy[$i] = $stmt[$i]->fetchColumn();
        $stmt[$i] = $db->query('SELECT slug FROM wp_terms WHERE term_id = '.$t_id[$i].'');
        $t_slug[$i] = $stmt[$i]->fetchColumn();
      }
        echo $xml;
     for ($i=0; $i<2; $i++)

      {

        $xml.= "\n\t\t".'<url>'."\n";
        $xml.= "\t\t\t".'<loc>'."http://domain.com/search-page/?$t_taxonomy[$i]=$t_slug[$i]"."\t$t_id[$i]\t$i\t$rowcount".'</loc>';
        $xml.= "\n\t\t\t".'<changefreq>always</changefreq>';
        $xml.= "\n\t\t\t".'<priority>1.0</priority>';
        $xml.= "\n\t\t".'</url>'."\n";
      }
    ?>


<?php 
$xml.= "\n".'</urlset>';
$handle = fopen('sitemap_custom.xml','w+');
fwrite($handle,$xml);
fclose($handle);
?>  


What I Need?

I want to extract next row term_id (ideal if it based on loop[0,1,2]) right now it shows me only result of term_id=365
Questionsingle DataSet having multiple DataTables from multiple databases Pin
Hailu Worku Obsse14-Jun-17 21:24
professionalHailu Worku Obsse14-Jun-17 21:24 
AnswerRe: single DataSet having multiple DataTables from multiple databases Pin
Richard Deeming15-Jun-17 1:51
mveRichard Deeming15-Jun-17 1:51 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Hailu Worku Obsse16-Jun-17 2:17
professionalHailu Worku Obsse16-Jun-17 2:17 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Richard Deeming16-Jun-17 2:22
mveRichard Deeming16-Jun-17 2:22 
AnswerRe: single DataSet having multiple DataTables from multiple databases Pin
Mycroft Holmes15-Jun-17 13:16
professionalMycroft Holmes15-Jun-17 13:16 
GeneralRe: single DataSet having multiple DataTables from multiple databases Pin
Eddy Vluggen16-Jun-17 3:18
professionalEddy Vluggen16-Jun-17 3:18 
QuestionError in SSIS Connection says (Test connection failed because of an error in initializing provider. ORA-12541: TNS:no listener) Pin
indian1437-Jun-17 13:12
indian1437-Jun-17 13:12 
AnswerRe: Error in SSIS Connection says (Test connection failed because of an error in initializing provider. ORA-12541: TNS:no listener) Pin
mike1402125-Jun-17 21:53
mike1402125-Jun-17 21:53 
QuestionI need advice on storing application level encrypted data. Pin
Gilbert Consellado5-Jun-17 18:26
professionalGilbert Consellado5-Jun-17 18:26 
SuggestionRe: I need advice on storing application level encrypted data. Pin
Kornfeld Eliyahu Peter5-Jun-17 20:50
professionalKornfeld Eliyahu Peter5-Jun-17 20:50 
QuestionHow do I write the insert sql statement for the following scenario ? Pin
karengsh3-Jun-17 22:30
karengsh3-Jun-17 22:30 
AnswerRe: How do I write the insert sql statement for the following scenario ? Pin
Mycroft Holmes4-Jun-17 13:49
professionalMycroft Holmes4-Jun-17 13:49 
GeneralRe: How do I write the insert sql statement for the following scenario ? Pin
karengsh4-Jun-17 20:41
karengsh4-Jun-17 20:41 
GeneralRe: How do I write the insert sql statement for the following scenario ? Pin
Mycroft Holmes4-Jun-17 20:58
professionalMycroft Holmes4-Jun-17 20:58 
GeneralRe: How do I write the insert sql statement for the following scenario ? Pin
karengsh4-Jun-17 22:12
karengsh4-Jun-17 22:12 
GeneralRe: How do I write the insert sql statement for the following scenario ? Pin
Mycroft Holmes5-Jun-17 12:05
professionalMycroft Holmes5-Jun-17 12:05 
GeneralRe: How do I write the insert sql statement for the following scenario ? Pin
karengsh10-Jun-17 19:12
karengsh10-Jun-17 19:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.