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

  • Home
  • SEARCH
  • 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 6199661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:13:45+00:00 2026-05-24T04:13:45+00:00

I’m not sure why this is happening. Here is my XML: <ResultSet> <chats> <chat>

  • 0

I’m not sure why this is happening. Here is my XML:

<ResultSet>
<chats>
    <chat>
        <messages>
            <sms>
                <from>Bisma Iqbal</from>
                <msg>Hi</msg>
                <sent>1311612055</sent>
            </sms>
            <sms>
                <from>Bisma Iqbal</from>
                <msg>Hi</msg>
                <sent>1311612068</sent>
            </sms>
            <sms>
                <from>Bisma Iqbal</from>
                <msg>Hi</msg>
                <sent>1311612074</sent>
            </sms>
            <sms>
                <from>Bisma Iqbal</from>
                <msg>Hi</msg>
                <sent>1311612186</sent>
            </sms>
        </messages>
        <contact>Bisma Iqbal</contact>
    </chat>
    <chat>
        <messages>
            <sms>
                <from>Javaid Iqbal</from>
                <msg>this is the first message</msg>
                <sent>1311612055</sent>
            </sms>
            <sms>
                <from>Javaid Iqbal</from>
                <msg>this is the second message</msg>
                <sent>1311612055</sent>
            </sms>
        </messages>
        <contact>Javaid Iqbal</contact>
    </chat>
    <chat>
        <messages>
            <sms>
                <from>Ankur Shahi</from>
                <msg>Wanna play dawg at 7:15</msg>
                <sent>1311632708</sent>
            </sms>
            <sms>
                <from>Ankur Shahi</from>
                <msg>Wanna play dawg at 7:15</msg>
                <sent>1311632708</sent>
            </sms>
            <sms>
                <from>Ankur Shahi</from>
                <msg>Wanna play dawg at 7:15</msg>
                <sent>1311632708</sent>
            </sms>
        </messages>
        <contact>Ankur Shahi</contact>
    </chat>
</chats>
</ResultSet>

Now, here is my code:

require_once('global.php');
$statement = $db->prepare("SELECT * FROM user WHERE id=1");
$statement->execute();
$result = $statement->fetchObject();
$string = $result->chats;
$chats = GBA($string, "<chat>", "</chat>"); //the XML I showed you

for($i = 0, $size = count($chats); $i < $size; ++$i) {
//for every chat:
    $all_sms = GBA($chats[$i], "<sms>", "</sms>");
    $name = GB($chats[$i], "<contact>", "</contact>");
    echo "<center><table border='1' cellpadding='5'><tr><td colspan='3' align='center'>SMS Chat with <i>{$name}</i></td></tr><tr><th>From</th><th>Message</th><th>Sent</th></tr>";

    for($j = 0, $size = count($all_sms); $j < $size; ++$j) {
    //for every sms in each chat
            $from = GB($all_sms[$j], "<from>", "</from>");
            $msg = GB($all_sms[$j], "<msg>", "</msg>");
            $sent = time_since(GB($all_sms[$j], "<sent>", "</sent>"));
            echo "<tr><td>{$from}</td><td>{$msg}</td><td>Sent: {$sent}   </td></tr>";
        }
    echo "</table><br /><br /></center>";
}

As you can see, everything looks fine but it only shows the first 2 tables, not the third! I have a debugged a lot to no conclusion.

  • 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-24T04:13:46+00:00Added an answer on May 24, 2026 at 4:13 am

    Inside the inner loop you reassign $size. The second chat group of sms has only 2 entries which causes the outer loop to terminate since $size = 2 and $i = 2. Jon Martin’s suggestion appears to work for your specific data but will fail in general case.

    I suggest

    for($j = 0, $jsize = count($all_sms); $j < $jsize; ++$j) {
    // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
In my XML file chapters tag has more chapter tag.i need to display chapters
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.