Ivaked Posted September 30, 2008 Share Posted September 30, 2008 http://myhawk.org/action/action.html?handle=*****&key=yallobzff7 The above link is my vital part when I seem to be struggling. Basically, I'm using the Drupal CMS for my website (www.warhawkinfo.com) and have recently acquired an XML feed for which I can parse the XML data and display the results on my site but I'm dumbfounded with PHP - it's something I've never tried to use before, and I've been stuck since the beginning. In the link you will see "*****". This variable can be any username which is associated with the game this XML feed is for. The value of which is to be defined using a form on my site e.g. if I put "Pot-Nut" into the form and click search the link would be "http://myhawk.org/action/action.html?handle=Pot-Nut&key=yallobzff7" which would then be parsed and the data returned to the user. The question is, how do I do this? I've tried a couple of methods with help from some friends on other forums but I have still not managed to get this working on my site. I'll be honest... I'm BEGGING for help with this as it's one of the most vital parts of my website which I need and any help anyone can give would not be thanked enough. Also, it will be my starting point for learning PHP! Very many thanks to any help in advance, it will be greatly appreciated. ~Liam Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/ Share on other sites More sharing options...
Ivaked Posted September 30, 2008 Author Share Posted September 30, 2008 Oh I forgot to mention - I've put this in the Drupal forum as I think it may need a slightly different workaround that a standard web-site due to the way Drupal works with 'nodes' and 'pages' - sorry if it is in the incorrect section. ~Liam Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/#findComment-653699 Share on other sites More sharing options...
haku Posted September 30, 2008 Share Posted September 30, 2008 If you want to get a variable in drupal, you don't attach it to the end the same way you would with a php variable. Instead, you structure the address differently. So instead of: http://myhawk.org/action/action.html?handle=*****&key=yallobzff7 You would make it: http://myhawk.org/action/******/yallobzff7 Then, you can access the various parts of that URL using arg(). Ex: arg(0) = action arg(1) = ********* arg(2) = yallobzff7 As you can see, the very first one (number zero) is action, as that is what comes after the first forward slash in the URL. The second one (number 1) is what comes after the next slash, and the third argument (number 2), is what comes after the next slash. Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/#findComment-653792 Share on other sites More sharing options...
Ivaked Posted September 30, 2008 Author Share Posted September 30, 2008 My apologies, I should have mentioned this in my first post. Myhawk.org is not my website - that is just the site that provides the varying XML feed. My website is warhawkinfo.com which is the Drupal site I want the parsed xml to appear on when a user searches using a form on my own site. ~Liam Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/#findComment-653796 Share on other sites More sharing options...
haku Posted October 1, 2008 Share Posted October 1, 2008 You are going to either have to install an XML reader module on your site, or create one. Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/#findComment-654510 Share on other sites More sharing options...
Ivaked Posted October 1, 2008 Author Share Posted October 1, 2008 Thank-you for your help - along with the help of others I have got it working using this code: <?php if (!isset($_GET['psnId'])) { echo '<form action="http://www.warhawkinfo.com/statchecker/" method="get"><p>Enter PSN ID: <input type="text" name="psnId" value="PSN" /></p><p><input type="submit" value="Search..." /></p></form>'; } else { $feedUrl = 'http://myhawk.org/action/action.html?handle=' . $_GET['psnId'] . '&key=yallobzff7'; $response = simplexml_load_file($feedUrl); if ($response !== FALSE) { echo '<a href="http://www.warhawkinfo.com/statchecker">New search...</a>'; echo '<br />'; echo '<br/>'; echo '<p>'; echo '<table>'; echo '<tr>'; echo "<th align=\"center\">Rank Image</th>"; echo "<th align=\"center\">Rank</th>"; echo '</tr>'; echo '<tr>'; echo "<td align=\"center\"><img src=\"" . $response->rankImage . "\"></td>"; echo '<td align ="center" style="vertical-align: middle"><b>' . $_GET['psnId'] . ' is currently a ' . $response->rank . '</b></td>'; echo '</tr>'; echo '</tr>'; echo '</table>'; echo '<br />'; echo 'globalGamePoints = ' . $response->globalGamePoints . '<br />'; echo 'globalTeamScore = ' . $response->globalTeamScore . '<br />'; echo 'globalCombatScore = ' . $response->globalCombatScore . '<br />'; echo 'globalBonusScore = ' . $response->globalBonusScore . '<br />'; echo 'globalTime = ' . $response->globalTime . '<br />'; echo 'globalKills = ' . $response->globalKills . '<br />'; echo 'globalDeaths = ' . $response->globalDeaths . '<br />'; echo 'globalKdr = ' . $response->globalKdr . '<br />'; echo 'globalAccuracy = ' . $response->globalAccuracy . '<br />'; echo 'globalWins = ' . $response->globalWins . '<br />'; echo 'globalLosses = ' . $response->globalLosses . '<br />'; echo 'globalWinLossRatio = ' . $response->globalWinLossRatio . '<br />'; echo 'globalScorePerMinute = ' . $response->globalScorePerMinute . '<br />'; echo 'globalDmScore = ' . $response->globalDmScore . '<br />'; echo 'globalTdmScore = ' . $response->globalTdmScore . '<br />'; echo 'globalHeroScore = ' . $response->globalHeroScore . '<br />'; echo 'globalColScore = ' . $response->globalColScore . '<br />'; echo 'globalMilesWalked = ' . $response->globalMilesWalked . '<br />'; echo 'globalMilesDriven = ' . $response->globalMilesDriven . '<br />'; echo 'globalMilesFlown = ' . $response->globalMilesFlown . '<br />'; echo 'globalGamePointsRank = ' . $response->globalGamePointsRank . '<br />'; echo 'globalTeamScoreRank = ' . $response->globalTeamScoreRank . '<br />'; echo 'globalCombatScoreRank = ' . $response->globalCombatScoreRank . '<br />'; echo 'globalBonusScoreRank = ' . $response->globalBonusScoreRank . '<br />'; echo 'globalTimeRank = ' . $response->globalTimeRank . '<br />'; echo 'globalKillsRank = ' . $response->globalKillsRank . '<br />'; echo 'globalDeathsRank = ' . $response->globalDeathsRank . '<br />'; echo 'globalKdrRank = ' . $response->globalKdrRank . '<br />'; echo 'globalAccuracyRank = ' . $response->globalAccuracyRank . '<br />'; echo 'globalWinsRank = ' . $response->globalWinsRank . '<br />'; echo 'globalLossesRank = ' . $response->globalLossesRank . '<br />'; echo 'globalWinLossRatioRank = ' . $response->globalWinLossRatioRank . '<br />'; echo 'globalScorePerMinuteRank = ' . $response->globalScorePerMinuteRank . '<br />'; echo 'globalDmScoreRank = ' . $response->globalDmScoreRank . '<br />'; echo 'globalTdmScoreRank = ' . $response->globalTdmScoreRank . '<br />'; echo 'globalHeroScoreRank = ' . $response->globalHeroScoreRank . '<br />'; echo 'globalColScoreRank = ' . $response->globalColScoreRank . '<br />'; echo 'globalMilesWalkedRank = ' . $response->globalMilesWalkedRank . '<br />'; echo 'globalMilesDrivenRank = ' . $response->globalMilesDrivenRank . '<br />'; echo 'globalMilesFlownRank = ' . $response->globalMilesFlownRank . '<br />'; echo 'dailyGamePoints = ' . $response->dailyGamePoints . '<br />'; echo 'dailyTeamScore = ' . $response->dailyTeamScore . '<br />'; echo 'dailyCombatScore = ' . $response->dailyCombatScore . '<br />'; echo 'dailyBonusScore = ' . $response->dailyBonusScore . '<br />'; echo 'dailyTime = ' . $response->dailyTime . '<br />'; echo 'dailyKills = ' . $response->dailyKills . '<br />'; echo 'dailyDeaths = ' . $response->dailyDeaths . '<br />'; echo 'dailyKdr = ' . $response->dailyKdr . '<br />'; echo 'dailyAccuracy = ' . $response->dailyAccuracy . '<br />'; echo 'dailyWins = ' . $response->dailyWins . '<br />'; echo 'dailyLosses = ' . $response->dailyLosses . '<br />'; echo 'dailyWinLossRatio = ' . $response->dailyWinLossRatio . '<br />'; echo 'dailyScorePerMinute = ' . $response->dailyScorePerMinute . '<br />'; echo 'dailyDmScore = ' . $response->dailyDmScore . '<br />'; echo 'dailyTdmScore = ' . $response->dailyTdmScore . '<br />'; echo 'dailyHeroScore = ' . $response->dailyHeroScore . '<br />'; echo 'dailyColScore = ' . $response->dailyColScore . '<br />'; echo 'dailyMilesWalked = ' . $response->dailyMilesWalked . '<br />'; echo 'dailyMilesDriven = ' . $response->dailyMilesDriven . '<br />'; echo 'dailyMilesFlown = ' . $response->dailyMilesFlown . '<br />'; echo 'dailyGamePointsRank = ' . $response->dailyGamePointsRank . '<br />'; echo 'dailyTeamScoreRank = ' . $response->dailyTeamScoreRank . '<br />'; echo 'dailyCombatScoreRank = ' . $response->dailyCombatScoreRank . '<br />'; echo 'dailyBonusScoreRank = ' . $response->dailyBonusScoreRank . '<br />'; echo 'dailyTimeRank = ' . $response->dailyTimeRank . '<br />'; echo 'dailyKillsRank = ' . $response->dailyKillsRank . '<br />'; echo 'dailyDeathsRank = ' . $response->dailyDeathsRank . '<br />'; echo 'dailyKdrRank = ' . $response->dailyKdrRank . '<br />'; echo 'dailyAccuracyRank = ' . $response->dailyAccuracyRank . '<br />'; echo 'dailyWinsRank = ' . $response->dailyWinsRank . '<br />'; echo 'dailyLossesRank = ' . $response->dailyLossesRank . '<br />'; echo 'dailyWinLossRatioRank = ' . $response->dailyWinLossRatioRank . '<br />'; echo 'dailyScorePerMinuteRank = ' . $response->dailyScorePerMinuteRank . '<br />'; echo 'dailyDmScoreRank = ' . $response->dailyDmScoreRank . '<br />'; echo 'dailyTdmScoreRank = ' . $response->dailyTdmScoreRank . '<br />'; echo 'dailyHeroScoreRank = ' . $response->dailyHeroScoreRank . '<br />'; echo 'dailyColScoreRank = ' . $response->dailyColScoreRank . '<br />'; echo 'dailyMilesWalkedRank = ' . $response->dailyMilesWalkedRank . '<br />'; echo 'dailyMilesDrivenRank = ' . $response->dailyMilesDrivenRank . '<br />'; echo 'dailyMilesFlownRank = ' . $response->dailyMilesFlownRank . '<br />'; echo '</p>'; } else { echo '<p>Failed to open the feed - Myhawk may be down.</p>'; } } ?> EDIT - Scratch that - I got the error checking working lol. ~Pot-Nut Quote Link to comment https://forums.phpfreaks.com/topic/126417-drupal-parse-xml-and-display-results-on-a-page/#findComment-654551 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.