Jump to content

kristen

Members
  • Posts

    22
  • Joined

  • Last visited

Everything posted by kristen

  1. I imagine this is an easy one for you all! I actually asked a very similar question probably 10 years ago, doesn't seem to be a way to find it in my history though :/ Thanks in advance for helping out a very, very casual coder. I have a query that pulls events from my table. Events use `date` field if it is on a specific date, or the `date_from` and `date_to` fields if they occur over a range of dates. SELECT * FROM cms_events WHERE county_id='7' AND status='1' and ((`date_to`>='2015-12-10' || `date`>='2015-12-10')) ORDER BY date_from,date,name ASC Returned on the page, I would like to have a header separating events by date. So it would print "December 10", list results for 2015-12-10, then "December 11", list results for 2015-12-11, etc. Then at the end, "Ongoing" events, which are the ones using date_from and date_to fields. Thank you for your help!
  2. Hello, Does anyone know what might cause a slow connection when attempting to load a page? This is the page - http://www.parentguidenews.com/Calendar/NewYork/NassauCounty/. If you look at your status bar after you hit "Go", you'll see that there is a long delay while the browser is "Connecting..." then a pretty short "Loading..." before the page comes up in full. I just don't understand it. All of the pages on the site are pretty ad-heavy and will have a long-ish loading time while the images download, but none have the "connecting" lag. My boss says I need to fix this and I really have NO idea what it could be. Please help! Thanks, Kristen
  3. Bumping this, hoping someone can help... thanks!
  4. Could you please elaborate on this? I am drawing a blank on how I would re-order after stripping those characters. Thanks!
  5. Hi, I have googled extensively on this subject and just cannot find the answer, but it seems like it MUST exist! I have a list of articles in my database. I want to sort them alphabetically. "Okay," you say, "so pop in 'ORDER BY name' and you're good to go." Except that a few article titles are like in quotation marks, like "I Can't Take it Anymore!" - so these show up at the top of the list. I want to run the query, escaping symbols so that the articles show up properly in the list, instead of those that begin with symbols staying at the top. Does anyone know how to do this? Thanks!
  6. Thanks for the quick reply. Re: analyzing errors - how about printing them out in full? All I get right now is "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0 LIMIT 1' at line 1"
  7. Normally, when I run a query, it is in this format: $query = "SELECT * FROM table where id='$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo $query; which I like, because then I can add that "echo $query;" at the end and make sure all my variables are passing correctly. However, now I am forced to work within someone elses code, and I need to be sure that I am querying what I want to be querying, and the format is like this: return $this->_db->sql_select_one("table", '*', array('id'=>$id)); return array(); How can I print out what the query is that I am using? Thanks for any help, I am fairly new at this and I am driving myself crazy here!!
  8. Hello everyone, Does anyone know of a forum software that has built-in ad support? My client is looking for a very specific setup, similar to http://www.lifamilies.com/chat/ in that there are 6 or so small ads in the right sidebar of the page. I want to make this as easy on myself as possible - therefore, building my own CMS for ad management is undesirable - but if unavoidable, what forum software will allow me to modify the template to include that ad column? I'm sorry if I sound confused, I am, I am losing my mind over this project. Please ask any questions you feel are relevant and I will answer ASAP. Thank you!!
  9. Thank you, but it's not really what I was looking for. Your code is for a dropdown menu, this is for a navigation menu.
  10. I have a standard left hand menu that is generated from a database. My problem is that I would like the submenu to only show up when it's parent topic is active. For example, when someone is on this page http://www.naccrra.org/membership/, the "Frequently Asked Qs" link should be hidden. Here is the code: <? $query = "SELECT * FROM naccrra_web.site_nav where display = 'Y' and topic = '".$topic."' and level = '1' order by seq"; //echo $query; $result = prod_query($query); $num_rows = mysql_num_rows($result); if ($num_rows!="0") { ?> <ul class="menu"> <? $rawpath = $_SERVER['PHP_SELF']; $pathchunks = explode("/", $rawpath); $folder = $pathchunks[1]; while($row = mysql_fetch_array($result)) { ?> <li><a href="<? echo $row['link']; ?>"<? if ($row['class']!="") { echo " class=".$row['class']; } ?><? if ($row['link']==$path) { echo " class=\"active\""; } ?>><? echo $row['text']; ?></a></li> <? if ($row['has_child']=="Y") { $query2 = "SELECT * FROM naccrra_web.site_nav where topic='".$topic."' and level='2' and parent_id='".$row['id']."' order by seq desc"; //echo $query2; $result2 = prod_query($query2); while($row2 = mysql_fetch_array($result2)) { ?> <ul class="submenu"> <li><a href="<? echo $row2['link']; ?>"<? if ($row2['class']!="") { echo " class=".$row2['class']; } ?><? if ($row2['link']==$path) { echo " class=\"active\""; } ?>><? echo $row2['text']; ?></a></li> </ul> <? } } } ?> </ul> <? } ?> Thanks for any help!
  11. For anyone interested, I did end up figuring it out (kind of). It works now, I'm just not sure it is the best way to do it. Here is my final code: <? header('Content-type: application/xml'); ?> <? echo "<?";?>xml version="1.0" encoding="iso-8859-1"<? echo "?>";?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>Are You Aware En Español</title> <description>A Bi-weekly Feature, Presented By Child Care Aware</description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/</link> <atom:link href="http://www.childcareaware.org/feeds/aya_sp.rss" rel="self" type="application/rss+xml" /> <? $query = "SELECT * FROM sp_articles ORDER BY id DESC LIMIT 10"; $result = cca_areyouaware_db_query($query); while ($row = mysql_fetch_array($result)){ $title_output = $row[title]; $badchars = array("<", ">", "&", "“", "’", "”", "–", "—"); $goodchars = array("<", ">", "&", "'", "'", "'", "-", "-"); $body_output = str_replace($badchars, $goodchars, $row[body]); ?> <item> <title><?= $title_output; ?></title> <description><?= $body_output; ?></description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></link> <guid>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></guid> </item> <? } ?> </channel> </rss> Thanks for the help!
  12. Try nl2br http://us3.php.net/nl2br
  13. Can you be a bit more specific? I changed encoding to UTF-8, added utf8_encode, and it just changes the set of errors - I think because the spanish characters in my code are in the format "É", not É. Thank you for the help, I really appreciate it... this has been on my list of to-dos for over a year, and I just keep getting frustrated and giving up. Hopefully this time I'll get it! New code: <? header('Content-type: text/xml'); ?> <? echo "<?"; ?>xml version="1.0" encoding="UTF-8"<? echo "?>"; ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title><? echo utf8_encode($feedtitle); ?></title> <description>A Bi-weekly Feature, Presented By Child Care Aware</description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/</link> <atom:link href="http://www.childcareaware.org/feeds/aya_sp.rss" rel="self" type="application/rss+xml" /> <? $query = "SELECT * FROM sp_articles ORDER BY id DESC LIMIT 10"; $result = cca_areyouaware_db_query($query); while ($row = mysql_fetch_array($result)){ $title_output = utf8_encode($row[title]); $body_output = utf8_encode($row[body]); ?> <item> <title><?= $title_output; ?></title> <description><?= $body_output; ?></description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></link> <guid>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></guid> </item> <? } ?> </channel> </rss> Again, validation is here: http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.childcareaware.org%2Ffeeds%2Faya_sp.rss
  14. If I switch to UTF-8, I just get different errors. You can see them here: http://feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.childcareaware.org%2Ffeeds%2Faya_sp.rss
  15. Probably not... I was just trying a bunch of different combinations to see if I could get anything to work. This doesn't hurt, but doesn't help either.
  16. I know this is not strictly a PHP question, but I hope someone can help me nonetheless. I have an RSS feed here http://www.childcareaware.org/feeds/aya_sp.rss. The content comes from a database, so the .rss file has some PHP in it to make that happen. It sounds a little weird, but it works fine. The problem is that the content coming in has Spanish characters (e.g. é), which cannot be read by xml parsers, and cause the feed to fail. I think that I need to declare a DTD, but after extensive googling and experimentation, I can't seem to find anything that works. Code is below... (minus the function cca_areyouaware_db_query, for security purposes) <? header('Content-type: text/xml'); ?> <? echo "<?"; ?>xml version="1.0" encoding="ISO-8859-1"<? echo "?>"; ?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <title>Are You Aware? En Español</title> <description>A Bi-weekly Feature, Presented By Child Care Aware</description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/</link> <atom:link href="http://www.childcareaware.org/feeds/aya_sp.rss" rel="self" type="application/rss+xml" /> <? $query = "SELECT * FROM sp_articles ORDER BY id DESC LIMIT 10"; $result = cca_areyouaware_db_query($query); while ($row = mysql_fetch_array($result)){ $title_output = preg_replace('/[^\x20-\x7F]+/', '', $row[title]); $body_output = preg_replace('/[^\x20-\x7F]+/', '', htmlentities($row[body])); ?> <item> <title><?= $title_output; ?></title> <description><?= $body_output; ?></description> <link>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></link> <guid>http://www.childcareaware.org/sp/subscriptions/areyouaware/article.php?id=<?= $row['id']; ?></guid> </item> <? } ?> </channel> </rss> Thanks for any help you can give!
  17. Thanks, I've always been curious about this. I've seen it all three ways, but I normally use the 2nd.
  18. Thank you Kevin! It is SO close. Here is my current code: $query = "select date_format(date, '%Y') as year from pr group by year order by year desc"; // select all the years $result = prod_query($query); while ($row = mysql_fetch_array($result)) { echo "<h3>".$row[year]."</h3>"; $query2 = "SELECT id, title, date_format(date,'%M %d, %Y') as date, date_format(date, '%Y') as year FROM pr WHERE del='N' and post='Y' and year='".$row['year']."' ORDER BY id DESC"; echo $query2; $result2 = prod_query($query2); while ($row2 = mysql_fetch_array($result2)){ echo "<p><strong><a href=\"/news/press_releases/full.php?id=$row2[id]\">$row2[date]</a></strong>: $row2[title]</p>"; } } You can see my test page here: http://www.naccrra.org/news/press_releases/pr_test.php I believe that the problem is that I can't use year as a part of the WHERE part of the query because it was only just declared in the SELECT part of the query. Is this correct? Anyone have an idea on getting around this? Thank you so much everyone.. I appreciate all of your input!
  19. <?php echo $row['id']; ?> OR <? echo $row['id']; ?> OR <?=$row['id']; ?>
  20. Should be fairly simple... but I'm a beginner, and google isn't helping! I have a table called "Press Releases" that I connect to and then print out so that the releases from each year are separated from each other with a header specifying the year. Right now this is what I am using: <h3>2008</h3> <?php $query = "SELECT id, title, date_format(date,'%M %d, %Y') as date, date_format(date, '%Y') as year FROM pr WHERE del='N' and post='Y' ORDER BY id DESC"; $result = prod_query($query); while ($row = mysql_fetch_array($result)){ if ($row['year'] == '2008') { echo "<p><strong><a href=\"/news/press_releases/full.php?id=$row[id]\">$row[date]</a></strong>: $row[title]</p>"; } else { echo ''; } } ?> And so on, using that chunk of code (with a different value for $row[year]) several times to get the results from previous years. The code works fine, but I can't help but think there is a better way to go about it. The other problem is that in 2009, I'll need to manually add another chunk to get 2009 releases. Is there a way to make a loop or something to just print each year and it's releases? Thank you!
×
×
  • 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.