Jump to content

OhTheNoes

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Everything posted by OhTheNoes

  1. Hi all, I've got a couple of these event entries with dates attached to them in the format of day-month-year (example: 31-01-2001) and I've got a script to display the name+date in a list. How could I go about making it so that it orders by the oldest on top like: Event A October 5, 2011 - October 8, 2011 Event B October 6, 2011 - October 7, 2011 Event C October 9, 2011 - December 1, 2011 Any help would be appreciated
  2. Works perfectly. Thank you so much!
  3. Hello premiso, The code you gave me results in either /id/xxxx/ or /profiles/zzzz/ but I would like it to only output xxxx or zzzz Would that be possible?
  4. Sorry, I'm not very good at PHP, please bear with me... I tried doing this $pattern = '~^http://[\w\d]+\.[com|net|org|gov]/[\w\d]+/([\w\d])+/$~i'; //can add more extensions $subject = $urlInput preg_match($pattern,$subject,$matches); $urlResult = $matches[0]; //first match (bit of html code here so the php breaks into two) echo $urlResult but it's coming out as blank?
  5. Hi, I have a variable that is either formatted as: http://thedomain.com/id/xxxx/ or http://thedomain.com/profiles/dzdf/ The URL differs each time but is it possible to make a bit of code that extracts the string between the last two forward slashes? That is, if the variable is the first example, it will out put "xxxx" or if the variable is the second one, it will output "dzdf" but the output is not limited to these two. Sorry if I'm being a bit confusing. Any assistance is much appreciated
  6. Oh shoot, I can't believe I missed that. Shouldn't have been working at 5am really =/ Thank you, Denno!
  7. I apologize in advance for any misuse of terminology. I find that I am rather ignorant in such things. I'm working on a WordPress theme. Specifically on the part that shows the "next: link-to-next-post" and "previous: link-to-prev-post" links. Here is the code that I have: <?php $nextvar=next_post_link('%link'); $prevvar=previous_post_link('%link'); ?> <?php if (isset($nextvar)) { ?> <h3>Next</h3> <p><?php next_post_link('%link'); ?></p> <? } ?> <?php if (isset($prevvar)) { ?> <h3>Previous</h3> <p><?php previous_post_link('%link'); ?></p> <? } ?> The first part intends to check if the links exist. And this works fine. However, the only output I'm getting are the values of $nextvar and $prevvar. The headers are nonexistent. What's wrong? Any help is much appreciated, and I thank you in advance.
  8. Ah great. Fantastic. Thank you all for your help, not just with this problem, as I'm sure this will definitely help me a lot in the future. Thank you!
  9. Oh I see! Would that work with everything in the format of x=y and you want to get y?
  10. From the URL the user is visiting. I'm sorry if I made things look confusing What I meant from my title was how to get the album number which varies depending on the URL of the user.
  11. Sorry! I am not very familiar with PHP terminology so I may have misrepresented some things with my words of choice. What can I do to help clarify the situation?
  12. Fantastic. It works perfectly. You guys are the absolute best. Thanks very much salathe, MrAdam!
  13. Hello! Thank you for taking the time to help me out. The code will be placed in a template file which will be called(?) each time someone opens a gallery page. To give a wider view, I'm trying to insert a "back to album" link in each gallery page. My original, incorrect code: <?php $url=getPageURL(); $var=explode('album=',$url); $var=explode('?',$var[1]); ?> <?php $albumVar=$var[1] ?> Back to <a href="http://domain.com/gallery/?album=<?php echo $albumVar ?>">gallery</a> Do you suggest I go with the function you mentioned or would the code you supplied be alright for this purpose?
  14. Hello! Once again, I find myself in the need of help regarding PHP. What I have is a URL that looks like this: http://domain.com/gallery/?album=3&gallery=65 What I need is to extract the number that comes after "album=". In this case, it would be the number 3. I currently have this: <?php $url=getPageURL(); $var=explode('album=',$url); $var=explode('?',$var[1]); ?> My problem is that it doesn't result in anything. Can anyone lend a hand? It would be much appreciated.
  15. Is it possible to make this function only work if the RSS feed URL is available? That is, so that it won't display an error if the RSS is missing/unavailable? Much thanks in advance for any help! <?php function parseRSS($url) { $feedeed = implode('', file($url)); $parser = xml_parser_create(); xml_parse_into_struct($parser, $feedeed, $valueals, $index); xml_parser_free($parser); foreach($valueals as $keyey => $valueal){ if($valueal['type'] != 'cdata') { $item[$keyey] = $valueal; } } $i = 0; foreach($item as $key => $value){ if($value['type'] == 'open') { $i++; $itemame[$i] = $value['tag']; } elseif($value['type'] == 'close') { $feed = $values[$i]; $item = $itemame[$i]; $i--; if(count($values[$i])>1){ $values[$i][$item][] = $feed; } else { $values[$i][$item] = $feed; } } else { $values[$i][$value['tag']] = $value['value']; } } return $values[0]; } $xml = parseRSS("http://domain.com/feed/"); foreach($xml['RSS']['CHANNEL']['ITEM'] as $item) { $fDate = mb_substr ($item['PUBDATE'],5,11); echo("<p>Last updated: <a href=\"{$item['LINK']}\">"); echo($fDate); echo("</a></p>"); break; } ?>
  16. Fantastic. It works perfectly! Thank you very much!
  17. Hi. I'm working with a code I found online for parsing WordPress RSS. What I'd like to do is display something in this format: <a href="BlogEntry">Date of Blog Entry</a> What I have with the code now is exactly what I want, except it displayed the 10 latest entries. I only want to display the latest one. Without changing any WordPress settings, how can I limit it to display only the latest entry? Any help would be appreciated as I have very little PHP knowledge. Thank you! 1. <?php function parseRSS($url) { 2. $feedeed = implode('', file($url)); 3. $parser = xml_parser_create(); 4. xml_parse_into_struct($parser, $feedeed, $valueals, $index); 5. xml_parser_free($parser); 6. foreach($valueals as $keyey => $valueal){ 7. if($valueal['type'] != 'cdata') { 8. $item[$keyey] = $valueal; 9. } 10. } 11. $i = 0; 12. foreach($item as $key => $value){ 13. if($value['type'] == 'open') { 14. $i++; 15. $itemame[$i] = $value['tag']; 16. } elseif($value['type'] == 'close') { 17. $feed = $values[$i]; 18. $item = $itemame[$i]; 19. $i--; 20. if(count($values[$i])>1){ 21. $values[$i][$item][] = $feed; 22. } else { 23. $values[$i][$item] = $feed; 24. } 25. } else { 26. $values[$i][$value['tag']] = $value['value']; 27. } 28. } 29. return $values[0]; 30. } 31. $xml = parseRSS("http://www.domain.com/category/feed/"); 32. foreach($xml['RSS']['CHANNEL']['ITEM'] as $item) { 33. $fDate = mb_substr ($item['PUBDATE'],5,11); 34. echo("<p>Latest update: <a href=\"{$item['LINK']}\">"); 35. echo($fDate); 36. echo("</a></p>"); 37. } 38. ?>
×
×
  • 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.