Jump to content

denhamd2

Members
  • Posts

    81
  • Joined

  • Last visited

Everything posted by denhamd2

  1. Awesome! Works perfectly! Thanks so so much!
  2. Thanks for this advice. Unfortunately I do not have access to a database, so I need to use just XML. The level I need them sorted is instead of within each league, it should be within each sport. How hard would it be to do this?
  3. So by re-structuring the array, do you mean having the top level be the date? Like so?... Array ( [201301041400] => Array { [Town Rovers vs Chanel] => Array ( [0] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link1.html ) [1] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link2.html ) [2] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link3c.html ) [3] => Array ( [0] => CHANNEL [1] => LANG [2] => KBPS [3] => link4.html ) ) ) }
  4. Thanks again for your help with this. It now filters by date but only within the scope of each tournament. Is it possible to do an absolute filter by date with all tournaments?
  5. Many thanks that's brilliant I just realised my list of events is not outputting in order of nearest date and time first... would you have any idea how to do this please? I promise this is the last question - thanks so much again!
  6. Excellent, this works a charm - thanks so much! One last thing ... I'm trying to output the time and date from the XML node "thetime" in the format: Blue League - Blue United vs FC Turf - 29th December 2013, 16:00 Any idea how I'd do this? Thanks again
  7. This is perfect, thanks so much again. In terms of outputting it in HTML, I'm trying to output it like below: Football Red League - Town Rovers vs Chanel Link 1: 300: en: link1.html Link 2: 300: en: link2.html Link 3: 300: en: link3.html Link 4: 300: en: link4.html Blue League - Blue United vs FC Turf Link 5: 200: en: link5.html Link 6: 300: de: link6.html Link 7: 500: en: link7.html Link 8: 300: en: link8.html I just can't get my head around how to use the perfectly formatted array you gave me to do this. I just keep getting errors. Any last help you could offer would be hugely appreciated!
  8. Thats brilliant thanks! The only things that are missing are the sportname, tournamentname and thetime - any idea how to include those in the array? Thanks again for your help
  9. Hi, In the XML I posted, you can see them as attributes: <link lang="en" kbps="300" channelname="Link 1"> Any idea how I'd pull them out to replace your hard coded values?
  10. Thanks for your reply - I've updated my code. For the attributes in the array you pasted, will the channel name output as "Link 3" or literally "CHANNEL"? Also, I'm not able to output my HTML for some reason. Here is my code: foreach ($acopy AS $thematches) { $singlematchname = strtolower($thematches->matchname); // FORMAT $singlematchlinks = ''; // LOOP THROUGH ALL LINKS foreach ($thematches->linkset->link AS $link) { $singlematchlinks .= '<div class="matchrow"><div class="channelname">'.$link["channelname"].'</div><div class="language">'.$link["lang"].'</div><div class="kbps">'.$link["kbps"].'</div><div class="link"><a href="'.$link.'" target="_blank">Watch</a></div><div class="clearb"></div></div>'; } echo '<h5>'.$singlematchname.'</h5>'.$singlematchlinks; } This gives the error: Warning: Invalid argument supplied for foreach() in /home/freefoot/public_html/newsite/read_test2.php on line 55 Line 55 starts with: foreach ($thematches->linkset->link AS $link) Any idea what I might be doing wrong?
  11. Hi, I have an XML files of sports events (see below). Some of the events have the same match name, so I've put everything into an array and then tried to match them using matchname as a key. The XML looks like this: <match><sportname>Football</sportname><tournamentname>Red League</tournamentname><thetime>201311021245</thetime><matchname dateandtime="1383396300">Town Rovers vs Chanel</matchname><linkset><link lang="en" kbps="300" channelname="Link 1">link1.html</link><link lang="en" kbps="350" channelname="Link 2">link2.html</link></linkset></match> <match><sportname>Football</sportname><tournamentname>Red League</tournamentname><thetime>201311021245</thetime><matchname dateandtime="1383396300">Town Rovers vs Chanel</matchname><linkset><link lang="en" kbps="320" channelname="Link 3">link3c.html</link><link lang="en" kbps="320" channelname="Link 3">link4.html</link></linkset></match> Here's my PHP code (I'm pulling in the XML file using SimpleXML)... $xml = simplexml_load_file('test3.xml'); $aCopy = array(); foreach ($xml->match AS $match) { if (!isset($aCopy[(string)$match->matchname])) { $aCopy[(string)$match->matchname] = $match; } else { foreach ($match->linkset->link AS $link) { $aCopy[(string)$match->matchname]->linkset->addChild('link', $link); } } } The code above seems to have gotten me 80% of the way in that they are matching ok and the links output ok. But the weird thing is the attributes on the 2nd instance of the match aren't outptting... Link 1 en 300 link1.html Link 2 en 350 link2.html [blank] [blank] [blank] link3.html [blank] [blank] [blank] link4.hmtl (Where [blank] is supposed to be the channelname, lang and kbps outputted attributes) Any suggestions on what I might be doing wrong here? Thanks in advance for any help you can offer.
  12. HI, How would you change the array structure? Also this needs to come from an XML file rather than a DB.
  13. I have a muli-dimensional array (see below). I'm trying to use PHP to group matching events. Basically any matchname that is a duplicate (eg. Reds vs Whites) to group them together and group their linksets... Array ( [matches] => Array ( [match] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021600 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link1.html ) [0] => Array ( [sportname] => Football [tournamentname] => Prince League [thetime] => 201308021130 [matchname] => Blues vs Yellows [linkset] => Array ( [link] => link2.html ) ) [1] => Array ( [sportname] => Football [tournamentname] => Crown League [thetime] => 201308021000 [matchname] => Reds vs Whites [linkset] => Array ( [link] => link3.html ) ) ) ) ) I am trying to end up with Football: Reds vs Whites (201308021600) - Crown League Links: link1.html, link3.html Football: Blues vs Yellows (201308021130) - Prince League Links: link2.html I've been looking at the PHP manual but tearing my hair out trying to get it to output the above. Any ideas would be most welcome. Thanks
  14. Hi, I'm using Simple XML to read from an XML file. I've done a loop for each event. It gives me all the events back in the order of the XML file. However, instead I am trying to sort events by date. Any idea how I could do this? Please see my code below. FYI, the date and time is in UTC timestamp format (eg. 1377361800) Thanks in advance for your help. $newresult = $result->xpath("//match/matchname[.='$uniqueteam']/.."); foreach ($newresult as $newmatchlist) { $newmatch = trim($newmatchlist->{'matchname'}[0]); $sport = $newmatchlist->{'sportname'}[0]; $tournament = $newmatchlist->{'tournamentname'}[0]; $time=$newmatchlist->{'matchname'}[0]['dateandtime']; }
  15. Hi Sorry I'm a bit of a newb. Would you be able to explain more? Just a little confused, sorry Thanks for your help!
  16. Hi, I'm trying to take the content from table rows and reformat it. You can see a sample structure of the HTML below: <table><tr> <td class="fixData" align="right" width="40%">Team 1</td><td class="fixData" align="center" width="10%"> v </td><td class="fixData" align="left" width="40%">Team 2</td> <td class="fixData" align="right" width="10%"><a href="#">Results</a></td> </tr><tr> <td class="fixData" align="right" width="40%">Team 3</td><td class="fixData" align="center" width="10%"> v </td><td class="fixData" align="left" width="40%">Team 4</td> <td class="fixData" align="right" width="10%"><a href="#">Results</a></td> </tr></table> I'm trying to change it to: <tr> <td class="newfixData"><a href="result.php?Team1-Team2">Team 1 v Team 2</a></td> </tr> Any ideas how I could do this?
  17. Hi, Unofrtunately I have no access to the query. It needs to be done in PHP. Any help would be great!
  18. Hi, I have a date string being output from a database into a variable $date which looks like: $date = "2010-09-30 12:45:52"; I'm trying to change the format to: 30 September 2010 (I want to get rid of the time also) Does anyone know how I could do this in PHP? Any help would be much appreciated!
  19. Hi, I'm trying to replace all instances of a HTML <span> tag with the class="eventname" with <strong> tags instead. Currently: <span class="eventname">Text here</span> Desired: <strong>Text here</strong> Any ideas how I'd do this using the preg match function in PHP? Thanks in advance!
  20. Hi, I have a date stored in variable $date in the format 12032008 I'm looking to create a new variable $datereformatted in the format 20080312,, would anyone know how to do this in PHP?
  21. I have a problem... I have text in a div class "schedulediv" which contains content which is dragged in dynamically and echo'ed as the variable $schedule. Basically all the headers are in <span> tags with the style "font-weight:bold" on them. I want to hide all the non-bold text, ie all the text in the div class .schedule that doesn't have a <span> tag around it. If possible I would like to to this without resorting to CSS... is it possible to extract all the <span> classes in the string $schedule and echo them with a <br> tag after each?
  22. Hi, I have set up a simple dropdown to list all the months a year from now and for the past year, so form July 2006 - Jun 2008. However, I am looking to have the current month as the selected option when the user first sees the page. Any ideas on how to do this? Here is my code currently: // Dropdown for months $out = "<select name=\"thedate\">\n"; for ($i = 0; $i < 12; $i++) { $ts = mktime(0,0,0,(date('m') + $i),1); $month = date('m', $ts); $monthname = date('F', $ts); $year = date('Y', $ts); $year = ($year-1); $out .= "<option value=\"$month$year\">$monthname $year</option>\n"; } for ($i = 0; $i < 12; $i++) { $ts = mktime(0,0,0,(date('m') + $i),1); $month = date('m', $ts); $monthname = date('F', $ts); $year = date('Y', $ts); $out .= "<option value=\"$month$year\">$monthname $year</option>\n"; } $out .= "</select>\n"; echo $out;
  23. ok here's what i have so far: i have my checkboxes in a repeat loop: <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_get_forum_messages['date']; ?>" /> then a submit button: <input name="delete" type="submit" id="delete" value="Delete"> then here's my php code: <?php if($_POST['delete'] == "Delete"){ for($j=0;$j<$num_rows;$j++){ $del_id = $checkbox[$j]; $sql = "DELETE FROM bookings WHERE date='$del_id'"; $result = mysql_query($sql); echo $result; } } ?> ... but it doesn't work, it doesnt delete any rows just reloads the page, any ideas?
  24. Hi, I have a form with a list of checkboxes, which are each filled with a date in the format 27012007, for example. The name of each of the checkboxes is the same as the date. Basically when the user presses the submit button I would like all rows in the database table "users" with the corresponding column "date" to be deleted when the form variables date correspond to those in the "date" rows. I think all the checked dates might also need to be put into an array. Would anyone know how to do this? Thanks in advance
×
×
  • 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.