Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to change child tag order in XML (Generated by PHP)
    text
    copied!<p>I have one application in flash in which multiple users can log in and can upload images. when user log in he can view images uploaded by him and also can view images uploaded by other users(only allowed images). for that i am generating xml file through php.</p> <p><strong>please check xml file.</strong></p> <pre><code>&lt;images&gt; &lt;users user_name="Hardik"&gt; &lt;image image_id="1316683023140" image_title="water" image_desc="water" image_path="all_users/Hardik/1316683023140.jpg" image_like="false"/&gt; &lt;image image_id="1316683057577" image_title="sunset" image_desc="sunset" image_path="all_users/Hardik/1316683057577.jpg" image_like="false"/&gt; &lt;image image_id="1316683115124" image_title="hills" image_desc="hills" image_path="all_users/Hardik/1316683115124.jpg" image_like="false"/&gt; &lt;image image_id="1316683713159" image_title="sun" image_desc="sun" image_path="all_users/Hardik/1316683713159.jpg" image_like="false"/&gt; &lt;image image_id="1316684544200" image_title="sun" image_desc="sun" image_path="all_users/Hardik/1316684544200.jpg" image_like="false"/&gt; &lt;image image_id="1316686014899" image_title="sun" image_desc="sun" image_path="all_users/Hardik/1316686014899.jpg" image_like="false"/&gt; &lt;image image_id="1316600184214" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600184214.jpg" image_like="false"/&gt; &lt;image image_id="1316668356801" image_title="hello" image_desc="hello" image_path="all_users/Hardik/1316668356801.jpg" image_like="false"/&gt; &lt;image image_id="1316600221759" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600221759.jpg" image_like="false"/&gt; &lt;image image_id="1316600193960" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600193960.jpg" image_like="false"/&gt; &lt;image image_id="1316600172938" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600172938.jpg" image_like="false"/&gt; &lt;image image_id="1316600144316" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600144316.jpg" image_like="false"/&gt; &lt;image image_id="1316600173551" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600173551.jpg" image_like="false"/&gt; &lt;image image_id="1316600177792" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600177792.jpg" image_like="false"/&gt; &lt;image image_id="1316496700758" image_title="sunset" image_desc="sunset" image_path="all_users/Hardik/1316496700758.jpg" image_like="false"/&gt; &lt;image image_id="1316252181829" image_title="allow" image_desc="allow" image_path="all_users/Hardik/1316252181829.jpg" image_like="false"/&gt; &lt;image image_id="1316690195793" image_title="asasdas" image_desc="asdasd" image_path="all_users/Hardik/1316690195793.jpg" image_like="false"/&gt; &lt;image image_id="1316600153509" image_title="asd" image_desc="asd" image_path="all_users/Hardik/1316600153509.jpg" image_like="false"/&gt; &lt;image image_id="1316408901775" image_title="winter" image_desc="winter" image_path="all_users/Hardik/1316408901775.jpg" image_like="false"/&gt; &lt;/users&gt; &lt;users user_name="raj"&gt; &lt;image image_id="1315996252734" image_title="abc" image_desc="abc" image_path="all_users/raj/1315996252734.jpg" image_like="false"/&gt; &lt;/users&gt; &lt;users user_name="sandip"&gt; &lt;image image_id="1315996256153" image_title="abc" image_desc="abc" image_path="all_users/sandip/1315996256153.jpg" image_like="false"/&gt; &lt;/users&gt; &lt;/images&gt; </code></pre> <p>i have one logical issue with my XML file (that is generated by PHP). now i want to change child tag order. i want to have child tag of a user (that is logged in) in first position.</p> <p>say if sandip logins his child tag should come first instead hardik.</p> <p><strong>you can check my php code here</strong></p> <pre><code>&lt;?php require_once('connection.php'); header('Content-type: text/xml'); echo "&lt;?xml version='1.0' encoding='UTF-8'?&gt;"; echo "&lt;images&gt;"; $id=''; $count=0; $result_1 = ''; $query = "select ui.userId as 'UI userId', ua.userName as 'UI userName', ui.imageId as 'UI ImageId', ul.imageId as 'UL ImageId' , ui.imageRights, ui.imagePath, ui.imageTitle, ui.imageDesc from user_account ua, (select * from user_images where userId=".$_REQUEST['userId']." or imageRights='Allow') as ui left join (select * from user_likes where userId=".$_REQUEST['userId'].") as ul on ui.imageId = ul.imageId where ua.userId=ui.userId order by ui.userId"; $result_row = mysql_query($query); while($row = mysql_fetch_array($result_row, MYSQL_ASSOC)) { if($id != $row['UI userId']) { if($count == 0) { $result_1 .= "&lt;users user_name='".$row['UI userName']."'&gt;"; } else { $result_1 .= "&lt;/users&gt;"; $result_1 .= "&lt;users user_name='".$row['UI userName']."'&gt;"; } $id = $row['UI userId']; } $result_1 .= "&lt;image image_id='".$row['UI ImageId']."' image_title='".$row['imageTitle']."' image_desc='".$row['imageDesc']."' image_path='".$row['imagePath']."' image_like='"; if($row['UL ImageId']) $result_1 .= "true"; else $result_1 .= "false"; $result_1 .= "' /&gt;"; $count++; if($count == mysql_num_rows($result_row)) $result_1 .= "&lt;/users&gt;"; } echo $result_1; echo "&lt;/images&gt;"; ?&gt; </code></pre> <p>if you have any better solution please forward.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload