So what I am trying to do is pass an array through an external XML file.....like the example below:

xml.php?Username=username1&Username=username2&Username=username3&Username=name4

I am somewhat new to PHP and am still learning as I go, and cannot figure out how to go about doing this.

Here is my PHP Code:

$query = "SELECT * FROM users ORDER BY Rand() LIMIT 100"; 
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)){

$username = $row['username'];
}

$xml_location = "http://localhost/xml.php?Username=$username";

Obviously this won't work....Again I can't figure out how to pass each name and add &Username= before it

Thanks in advanced

    i think you could show an example ....

    table users ??? ... what is there which columns
    and xml file

    and once again ... what do u want to do?

      Not 100% sure this is what you're looking for:

      $query = "SELECT * FROM users ORDER BY Rand() LIMIT 100";
      $result = mysql_query($query) or die(mysql_error());
      $usernames = array();
      while ($row = mysql_fetch_array($result))
      {
         $usernames[] = "User=" . urlencode($row['username']);
      }
      $xml_location = "http://localhost/xml.php?" . implode('&', $usernames);
      

      A few issues:

      1. You were inconsistent as to whether it should be "User=" or "Username=".

      2. If you are truly doing up to 100 such user names, the query string will probably end up being too long. (There is no hard-and-fast limit, but most browsers and some servers will enforce some maximum in the 1000-character range or something like that for the entire URL.)

        Thanks for the help that worked....Now it is on to the next step, hopefully you guys can help with that.

        I was using an XML Parser for one user and it worked just fine, but now with the added Usernames to the XML I am unable to parse the XML

        For example.....here is one users XML Data:

        <Info>
        <Username>Username1</Username>
        <Data>Here is some data</Data>
        <Info/>

        Here is an example passing two Usernames:

        <ArrayOfInfo>
        <Info>
        <Username>Username1</Username>
        <Data>Here is some data</Data>
        <Info/>
        <Info>
        <Username>Username2</Username>
        <Data>Data for username2</Data>
        <Info/>
        </ArrayOfInfo>

        Here is my full PHP Code now(minus DB connection):

        <?
        
        include_once "xml.php";
        $xml = new ParseXML;
        
        $query = "SELECT * FROM se_users ORDER BY Rand() LIMIT 10"; 
        $result = mysql_query($query) or die(mysql_error());
        $usernames = array(); 
        while($row = mysql_fetch_array($result)){
        
        $usernames[] = "Username=" .str_replace(" ","%20",($row['user_username']));
        $location = "http://localhost/xml.php?" . implode('&amp;', $usernames); 
        $parsed = $xml->LoadXML($usernames,$location);
        
        // XML INFO TAKEN
        $info = $parsed['ArrayOfInfo']['Info']['Username'];
        $info2 = $parsed['ArrayOfInfo']['Info']['Data'];
        }
        
        ?>

        I have attached xml.php

          In your example you are not properly closing your XML <info> tag... you want </info> not <info/>.

          Also, you started out talking about passing array through a GET request, and then switched it to XML. Which is it that you need help with? myscript.php?username[]=user1&username[]=user2&username[]=user550 ... etc... that should work for the question regarding passing arrays.

            The portion of my issues was solved in the posts above, so I am now moving on to my next issue...........I'll post a better example of XML Data

            I tried using SimpleXML to parse out Info, Info2, and Username for each UserInfo without success.

            <ArrayOfInfo>
            <UserInfo>
            <Details>
            <Info>Last seen 1 minute ago</Info>
            <Info2/>
            <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
            <Online>false</Online>
            </Details>
            <Username>Name</Username>
            </UserInfo>

            <UserInfo>
            <Details>
            <Info>Sitting Around</Info>
            <Info2>Some Text<Info2/>
            <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
            <Online>true</Online>
            </Details>
            <Username>Name2</Username>
            </UserInfo>
            </ArrayOfInfo>

              <Info2>Some Text<Info2/> -> <Info2>Some Text</Info2>

                <ArrayOfInfo>
                <UserInfo>
                <Details>
                <Info>Last seen 1 minute ago</Info>
                <Info2/> ----??? must be </Info2> .. but here you are closing info tag but where do you open it ??? where is <info> ??
                <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
                <Online>false</Online>
                </Details>
                <Username>Name</Username>
                </UserInfo>

                <UserInfo>
                <Details>
                <Info>Sitting Around</Info>
                <Info2>Some Text<Info2/> -----??? .. must be <Info2>Some Text</Info2>
                <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
                <Online>true</Online>
                </Details>
                <Username>Name2</Username>
                </UserInfo>
                </ArrayOfInfo>

                  Corrections to the XML

                  <ArrayOfInfo>
                  <UserInfo>
                  <Details>
                  <Info>Last seen 1 minute ago</Info>
                  <Info2>Some Text</Info2>
                  <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
                  <Online>false</Online>
                  </Details>
                  <Username>Name</Username>
                  </UserInfo>

                  <UserInfo>
                  <Details>
                  <Info>Sitting Around</Info>
                  <Info2>Some Text</Info2>
                  <LastSeen>2009-01-06T09:19:42-06:00</LastSeen>
                  <Online>true</Online>
                  </Details>
                  <Username>Name2</Username>
                  </UserInfo>
                  </ArrayOfInfo>

                    Write a Reply...