Jump to content


  • Posts

  • Joined

  • Last visited


Contact Methods

  • Website URL

Profile Information

  • Gender
    Not Telling

TEENFRONT's Achievements

Regular Member

Regular Member (3/5)



  1. strangely, also an example from the net returns empty aswell. $xml = ' <?xml version="1.0" encoding="ISO-8859-1"?> <cars> <make name="Ford"> <model>Mustang</model> </make> <make name="Honda"> <model>Accord</model> </make> </cars> '; $xml = simplexml_load_string($xml); echo $xml->make[0]['name']; that doesnt work either, just outputs nothing.
  2. Hey, Having some troubles extracting data from simpleXML object. var_dump outputs all the stuff correctly but when i try access data in the object, it just comes back empty. $rss = "/data/rss/"; $rss = file_get_contents($rss); // simplexml_load_file() fails $feed = new SimpleXMLElement($rss); foreach($feed->item as $news) { echo $news->title; // returns empty } echo $feed->item->title; // also is empty so var_dump($feed) outputs this, shortened version: object(SimpleXMLElement)#10 (2) { ["@attributes"]=> array(1) { ["version"]=> string(3) "2.0" } ["channel"]=> object(SimpleXMLElement)#11 (6) { ["title"]=> string(38) "Bradford Bulls Super League Rugby News" ["description"]=> string(75) "RSS Feed for the latest Bradford Bulls Super League rugby news and updates." ["link"]=> string(46) "http://www.superleaguefans.com/bradford-bulls/" ["language"]=> string(2) "en" ["pubDate"]=> string(26) "Sat, 03 Sep 13:42:39 +0100" ["item"]=> array(10){ [0]=> object(SimpleXMLElement)#12 (1) { ["title"]=> string(32) "Briggs and Walker in Bulls squad" } } } } so, $feed->item->title should return the ["title"] contents, but it doesn't, driving me crazy. what am i doing wrong? Any pointers will be much appreciated, thank you.
  3. Il mark this as solved as my original question is sorted. cheers!
  4. Hi, Cut down code SELECT count(number) FROM table GROUP BY title echo $title .'<br>'. $number; That outputs Title1 5 Title2 9 Title3 2 But what do i do if i wanted to retain and loop through the "$number" actual values, not JUST count the total? I still need access to what "$number" is while looping. But as GROUP BY returns one result.. im stuck. Ideally i want this as the resulting output title1 // grouped title 3 // total number of $numbers per grouped title 1234 12345 123456 // The actual values of $number totalling to the above grouped number title2 // grouped title 2 // total number of $numbers 1234 123456 // The actual values of $number totalling to the above grouped number
  5. Hi, Iv just changed it slightly as i now need to count the amount of INCIDENT_NO's per SCHEME_CODE. Iv got this.. $sql = "SELECT INCIDENT_NO, SCHEME_CODE FROM incidents WHERE JOB_DATE_TIME LIKE '$searchDate' AND SCHEME_CODE != '' ORDER BY SCHEME_CODE, INCIDENT_NO ASC"; $query = mysql_query($sql) or trigger_error('MySQL Error: ' . mysql_error()); $prev_code = ''; $num = ''; while ($row = mysql_fetch_assoc($query)) { if ($prev_code != $row['SCHEME_CODE']) { $prev_code = $row['SCHEME_CODE']; echo $num; $num =''; echo '<br />' . $prev_code . '<br />'; } $num++; } } that outputs ALLASS 5 CTLR 83 DHOL1 174 FMNI 37 FR 104 HEX 173 JMR 4 RANS 14 ROLR 2 SCAS 2 SDC 58 TE1 As you can see the last one TE1 is missing its count. I know why - its because the code is set to count the previous SCHEME_CODE then on outputting the new SCHEME_CODE, show the number of incidents, and the last one, doesnt have one after to show. Any advice? Or another way to count each incidents per title? The output looks like this (cut down) without the adding of incident amounts. ALLASS 1 2 3 4 CTLR 1 2 3 4 So what im doing is counting the amount of "numbers" (INCIDENT_NO's) per title (SCHEME_CODE) .. and running into an issue with the last one.
  6. MrAdam, That works perfectly! Many Many thanks!
  7. Sure i simply have a select like auggested above.. $query = "SELECT INCIDENT_NO, SCHEME_CODE FROM incidents WHERE JOB_DATE_TIME LIKE '$searchDate' ORDER BY SCHEME_CODE, INCIDENT_NO ASC"; $sql = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($sql)){ echo $row['SCHEME_CODE']; echo "<br>"; echo $row['INCIDENT_NO']; } That results in Adam 1 Adam 2 Adam 3 Becky 1 Becky 2 Becky 3
  8. Im trying to achieve what i posted above The results need to come out like this Adam 1 2 3 Becky 1 2 3 Charlie 1 2 3
  9. Thanks jake, That gets me these results Adam 1 Adam 2 Adam 3 Becky 1 Becky 2 Becky 3 etc etc How do i then group the results just by name?
  10. Hi Just a quick one. I want my output result to look like this. In its simplistic form I have 2 columns, NAME and NUMBER. Adam 1 2 3 Becky 1 2 3 Charlie 1 2 3 So the output results are grouped by the "name" field, then ordered by the "number" field. I thought it was GROUP BY, but that function is something else. Iv tried searching around but im unsure what you call this form of grouping results. Many Thanks!
  11. Hi All, Im doing something for work (unpaid lol) that basically takes 2 tables, links them, then seperates out the results into "chargable" and "non chargeable" ... I need a query that will basically do this. Im going to type out what i think should happen.. OK 2 tables, incidents and jobs. SELECT incidentNumber, code1 FROM incidents ---- This gets ALL the incidents from the 1st table and returns all the $incidentNumber's aswell as $code1 SELECT job FROM jobs WHERE incidentNumber = $incidentNumber ---- This is the 2nd table with a matching incidentNumber field that the same as the 1st table incidentNumber field . AND THEN SELECT job FROM jobs where code2 = $code1 ---- this selects all the jobs with a code2 from the 2nd table that matches code1 from the 1st table. The end result is to only select incident numbers from the incidents table that have a matching code1 and code2 in the jobs table. Where do i start? i need to join the queries and the tables somehow and pass code1 as a var to the last bit when matching code1 to code2.
  12. Thats fantastic! You have helped me out quite a few times... il buy you a coffee (paypal) if you pm me cheers!
  13. Thanks iv got this so far... SELECT team FROM `userfields` GROUP BY team ORDER BY COUNT(team) DESC This successfully orders by the teams with the most fans... and i can output the team name... so i have this 1. Leeds 2. Wigan 3. Warrington But how to i add the actual number of fans for each team?
  14. Hey ok, i have a mysql table that show which user supports which team. example table results: uid is userid and team is team name. uid team 3 leeds 6 wigan 1 leeds 9 warrington 2 wigan What i want to output is a "league table" showing how many supporters each team has.. the result needs to be this 1. Leeds (3fans) 2. Wigan (2fans) 3. Warrington (1fan) This would be $position. $team ($teamFans ) So the query needs to group by team name, then count the number of fans, then output the team name and number of fans. I can do the GROUP BY bit... and output all the team names a single time... but just lost on how im meant to count up the fans and pass $teamFans to the result.. Any help?
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.