Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 621107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:50:17+00:00 2026-05-13T18:50:17+00:00

I have a question that has me stumped, maybe you can help. I have

  • 0

I have a question that has me stumped, maybe you can help. I have the following php:

if(mysql_num_rows($result) > 0){
  //if so set up the xml
  $dom = new DOMDocument();
  $response = $dom->createElement('response');
  $encore = $dom->createElement('encoreSongs');
  $dom->appendChild($response);
  $previousDate = "";
  //if yes cycle through all results, checking their artist

  while($row = mysql_fetch_array($result)){
    //check if the current songs artist is in the artist array
    $song_name = $row['name'];
    $song_artist = $row['artist'];
    $song_date = $row['date'];
    $song_city = $row['city'];
    $song_state = $row['state'];
    $song_location = $song_city . ', ' . $song_state;
    $song_id = $row['unique_song_id'];
    $song_segue = $row['part_of_a_sugue'];

    $song_info = $dom->createElement('song');

    $idElement = $dom->createElement('song_id');
    $idText = $dom->createTextNode($song_id);
    $idElement->appendChild($idText);
    $song_info->appendChild($idElement);

    $nameElement = $dom->createElement('song_name');
    $nameText = $dom->createTextNode($song_name);
    $nameElement->appendChild($nameText);
    $song_info->appendChild($nameElement);

    $artistElement = $dom->createElement('song_artist');
    $artistText = $dom->createTextNode($song_artist);
    $artistElement->appendChild($artistText);
    $song_info->appendChild($artistElement);

    $dateElement = $dom->createElement('song_date');
    $dateText = $dom->createTextNode($song_date);
    $dateElement->appendChild($dateText);
    $song_info->appendChild($dateElement);

    $locationElement = $dom->createElement('song_location');
    $locationText = $dom->createTextNode($song_location);
    $locationElement->appendChild($locationText);
    $song_info->appendChild($locationElement);

    $segueElement = $dom->createElement('song_segue');
    $segueText = $dom->createTextNode($song_segue);
    $segueElement->appendChild($segueText);
    $song_info->appendChild($segueElement);

    //if the song is part of an encore, save it for later
    if($row['setOrEncore'] == 'encore'){
      $encore->appendChild($song_info);
    }

    else{
      /*if the previous song was an encore from another show and this song is a set,
      assume that the previous group of encores went with the previous show
      and append the encores before this new song/show */
      if($previousDate != $song_date){
        echo "tagged at " . $row['name'];
        //affix encore songs to 'response'
        $encore_songs = $encore->getElementsByTagName('song');
        foreach($encore_songs as $a){
          $response->appendChild($a);
        }
        //reset encore variable
        $encore = $dom->createElement('encoreSongs');  
      }
      //attach new song
      $response->appendChild($song_info);
    }

    $previousDate = $row['date'];
  }//end while  

My goal is to check if the current song if not an encore. If not I want to check and see if it has the same date as the previous song. If not, I want to add what I have in ‘$encore’ to the response and reset ‘$encore’. My problem is that ‘$previousDate’ (which is initialized to an empty string) is always the same as ‘$song_date’

can anyone see why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:50:17+00:00Added an answer on May 13, 2026 at 6:50 pm

    I’m sorry. The code works fine. The error was in what I was expecting from my data. Lesson learned. Thanks…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question that has had me stumped for a bit, I thought
I have a class called Question that has a property called Type. Based on
I have a UIView subclass ( CustomView for purposes of this question) that has
Fairly simple question: I have an init method on my class that has the
Similar to this question I have a custom subclass of UITableViewCell that has a
C# question (.net 3.5). I have a class, ImageData, that has a field ushort[,]
I realize that this question has been asked 100times but none that I have
From a previous question I have seen that the CLR has workstation and server
I have a rather theoretical question. My company has a working standard (documented) that
I have an issue that has me stumped. We have a model assembly and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.