Jump to content

rndilger

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Everything posted by rndilger

  1. Nevermind, I figured it out using a simpler php array solution.
  2. One more quick question. In the MySQL db, we used abbreviations for each state. I have an additional db that has the full state listing for each abbreviation. In my output, I'd like to display the full state name and I've already created the array ($state_array) in PHP for these purposes. Using the code provided by sasa, how do I go about identifying the individual state abbreviation and outputting the state name?
  3. Thanks! This code worked perfectly. I very much appreciate the input and would like to point out that my skills improve when I learn from contributions such as this. All the best, Ryan
  4. I'm trying to organize MySQL output in an HTML table based on individual states. Here is how the static HTML is currently displayed: http://www.u-s-s-a.org/breeders.html. Here is my working document: http://www.u-s-s-a.org/breeders.php. As you can see on the HTML page, each db row is organized into individual states. I'm only concerned about the US states, and not the countries outside of the US. Following is the code I've been working on (directoryoutput.php): <?php require '/home/srob/public_html/u-s-s-a.org/config.php'; $connect = mysql_connect ($dbhost, $dbuser, $dbpass) or die ('Cannot connect: '.mysql_error()); mysql_select_db ($dbname); $query = "SELECT * FROM directory ORDER BY flockname"; $result = mysql_query($query) or die ('Error, query failed.'); echo "<tr><td width='33%' class='style9'><p align='left' class='style12'><a name='AR'></a>Arkansas</p></td><td width='34%'> </td><td width='33%' valign='top'><div align='right'><a href='#TOP'><img src='returnTOTOPGRAPHIC/RETURNTOTOP.gif' width='113' height='21' border='0' align='absmiddle'></a></div></td></tr>"; $cnt = 0; while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ if ($cnt == 0){ echo "<tr><td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td>"; $cnt++; } elseif ($cnt == 1){ echo "<td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td>"; $cnt++; } elseif ($cnt == 2){ echo "<td valign='top' class='style9'><p align='center'><span class='style10'><strong>"; if($row['flockname']){ echo $row['flockname']; } echo "</strong></span><strong></br>"; if($row['firstname']){ echo $row['firstname']." ".$row['lastname']."</br>"; } if($row['address1']){ echo $row['address1']."</br>"; } if($row['address2']){ echo $row['address2']."</br>"; } if($row['city']){ echo $row['city'].", ".$row['state']." ".$row['zip']."</br>"; } if($row['email1']){ echo "<a href='mailto:".$row['email1']."'>".$row['email1']."</a></br>"; } if($row['email2']){ echo "<a href='mailto:".$row['email2']."'>".$row['email2']."</a></br>"; } if($row['website1']){ echo "<a target='_blank' href='http://".$row['website1']."'>".$row['website1']."</a></br>"; } if($row['website2']){ echo "<a target='_blank' href='http://".$row['website2']."'>".$row['website2']."</a></br>"; } echo "</br></p></td></tr>"; $cnt = $cnt - 2; } } mysql_close($connect); ?> I'd appreciate any help on this code, including a more efficient way to parse out the MySQL db rows into 3 columns in the HTML table. Thanks in advance! Ryan
  5. Great suggestion, I will try that. But I also just realized that it probably shouldn't be the fopen function that is failing. As I mentioned in my original post, I was able to output the contents of the array that contains the rssfeeds (see news page now: http://www.indianasheep.com/news) that shows output using: $filename = "/home/indiana/public_html/scripts/rss/rssfeeds.txt"; $fp = fopen($filename, 'rb'); if ($fp) { $rssfeeds = explode("\n", fread($fp, filesize($filename))); } foreach ($rssfeeds as $a) { echo $a."<br>"; //include ("http://www.indianasheep.com/scripts/rss/rss2html.php?TEMPLATE=output.php&XMLFILE=".$a."&MAXITEMS=10"); } unset($a); Therefore, it appears that the file is read just fine, but maybe the variables aren't being passed to the code in the include file? I'm not sure. Ryan
  6. No errors upon un-suppressing errors for fopen. And am I able to view the php.ini configuration file? I don't think I have access to it's location (/usr/local/lib/php.ini). My host swears they haven't changed anything on their end, except for the switch to a new server. Ryan
  7. Sorry, had to step out for a meeting. I checked the phpinfo on my server and it says "allow_url_fopen" is set to 'on' in both local and master. Also, I can't imagine that absolute paths would stop working all of a sudden. Other than checking them over, is there any way to debug this? Ryan
  8. Hello, I'm trying to debug code that was working before my webhost upgraded servers. Even though no code was changed, it no longer works. The page I'm referring to can be seen here: http://www.indianasheep.com/news. The script that runs on this page is supposed to collect rss news feeds and display on the items that contain certain keywords. I did not build the overall system, it is FeedForAll (http://www.feedforall.com/); I'm just trying to get the system working again. Basically, on the news page, I have it iterate through a txt file that contains all my rss feeds that need to be checked. Here is the code that does this: $filename = "/home/indiana/public_html/scripts/rss/rssfeeds.txt"; $fp = @fopen($filename, 'rb'); if ($fp) { $rssfeeds = explode("\n", fread($fp, filesize($filename))); } foreach ($rssfeeds as $a) { include ("http://www.indianasheep.com/scripts/rss/rss2html.php?TEMPLATE=output.php&XMLFILE=".$a."&MAXITEMS=10"); } unset($a); What the include does is pass variables to the actual rss2html.php file using output.php as the template. Here is the code from output.php: <table width="600"> <tr><td> <table bgcolor='#666666' border='0' cellpadding='0' cellspacing='0'> <tr> <td width='26' height='28'><img src='http://www.indianasheep.com/images/tl.png' width='26' height='28' border='0'></td> <td rowspan='2' align='center' width='548'><a href='~~~FeedLink~~~' style='text-decoration:none;' target='_blank'><h3 style='color:#FFF; padding:5px;'>~~~FeedTitle~~~</h3></a></td> <td width='26' height='28'><img src='http://www.indianasheep.com/images/tr.png' width='26' height='28' border='0'></td> </tr> <tr> <td width='26' height='30'><img src='http://www.indianasheep.com/images/bl.png' width='26' height='30' border='0'></td> <td width='26' height='30'><img src='http://www.indianasheep.com/images/br.png' width='26' height='30' border='0'></td> </tr> </table> </td></tr> ~~~BeginItemsRecord~~~ <?php $displayItem = 0; $file_key = "/home/indiana/public_html/scripts/rss/keywords.txt"; $fp = @fopen($file_key, 'rb'); if ($fp) { $keywords = explode("\n", fread($fp, filesize($file_key))); } foreach ($keywords as $b) { if ((stristr("~~~ItemTitle~~~", $b) !== FALSE) || (stristr("~~~ItemDescription~~~", $b) !== FALSE)) { $displayItem = 1; } } if ($displayItem == 1) { echo "<tr><td><br>~~~ItemPubLongDate~~~</td></tr> <tr><td style='padding-bottom:5px;'><a href='~~~ItemLink~~~' target='_blank'>~~~ItemTitle~~~</a></td></tr>"; } ?> ~~~EndItemsRecord~~~ </table> <br /><br /> So this just fills in a table with the rss feeds and the pertinent items that match keywords. The funny variables (e.g., ~~~ItemTitle~~~) are specific for the FeedForAll system, these must be used this way. If you look at the original news page, it appears to run none of the code. However, if I insert echo statements into the foreach loop, it gets outputted and I've verified that the txt file with rssfeeds is being read correctly (I can output everything from that array). So it appears that the information is not being passed to output.php. Here is a link to what it is supposed to output: http://www.indianasheep.com/scripts/rss/rss2html.php?TEMPLATE=output.php&XMLFILE=http://ars.usda.gov/news/rss/rss.htm&MAXITEMS=10. You'll notice that everything works, so I'm confused as to why the foreach loops are no longer working?! On a second note, I'd also like to modify this code to ONLY show those rss feeds for which news items contain specified keywords. When the code was working, it would still display a heading for each of the rss feeds specified in the txt file even if they didn't have any items that matched the keywords. I would really love if someone had input on this as well. Any advice? Thanks, Ryan
  9. Perfect, I wasn't in the right frame of mind to come up with that simple solution! Ryan
  10. The problem I'm having can be best described by looking at what I've current got at: http://www.indianasheep.com/memberlist. You'll notice that for the last entry (i.e., RndPig), there are 4 colored dots to the left of the MapIt button. In order to keep this system flexible, I'd like to have these dots arranged into lines of no more than 3 dots per line. Thus, for the RndPig record, I'd like 2 lines of dots (3 dots on first line, 1 dot on second line). The mysql db behind this listing contains a single row for each member and there are columns specifying to which categories a member belongs. What I'm currently doing is looping through and outputing colored dots that indicate whether a member belongs to a certain category. Here is the code I use to do this: for($i=0; $i<=count($field_names); $i++){ if (strtolower($row[$field_names[$i]]) == 'y'){ echo "<img src='images/map/mapmarker". $i .".gif' border='0' alt='". ucwords(str_replace("_"," ",$mem_type[$i])) ."'> "; } } ...where $field_names is an array that contains the actual column (field) names from the db and $row is an array that contains information as to which categories each member belongs (i.e., either a 'y' or a 'n'). This is where I need a little help. I don't know the best way to "paginate" the colored dots into rows of 3 as described above. Would this entail doing a count of the array elements in $row that equal 'y' and then using lots of if statements? Any help is appreciated. Thanks, Ryan
  11. Hello, I'm trying to figure out why the following code doesn't work, and I will admit that I'm green when it comes to JS so please bear with me. var chooseIcon = ["a","b","c","d","e,"f","g","h","i"]; var k = 1; for (k=1; k<=chooseIcon.length; k++) { var icon+ k + = new GIcon(); icon+ k +.image = "images/mapmarker"+ k +".gif"; icon+ k +.iconSize = new GSize(12, 12); icon+ k +.iconAnchor = new GPoint(0, 0); icon+ k +.infoWindowAnchor = new GPoint(5, 0); } All I want this code to do is to automate the writing of the following... var icon1 = new GIcon(); icon1.image = "images/mapmarker1.gif"; icon1.iconSize = new GSize(12, 12); icon1.iconAnchor = new GPoint(0, 0); icon1.infoWindowAnchor = new GPoint(5, 0); same thing with 2, 3, etc... I assume it's a simple fix, but I'm stumped at the moment. As always, thanks! Ryan
  12. Hello, I have a table from which I'd like to extract specific field names, only those that are prefixed with 'mem_'. These columns represent the different types of memberships allowed in an organization. The rest of the columns in the table hold information regarding the individual member (e.g., name, address, etc). My intent is to output the column names into a php array for use in other code, but I need a clean array of just these column headings. Here is the code I have so far: $field_names = array(); $cols = mysql_query("SHOW COLUMNS FROM `map`"); while($fields = mysql_fetch_assoc($cols)) { $f = $fields['Field']; if(substr(0,4) == "mem_") { $field_names[] = $f; } } print_r($field_names); This code just prints 'Array' over and over. Any advice? Thanks in advance. Ryan
  13. I seem to be going backwards here. Now the code just outputs: Array ( [Field] => mem_suppliers ) So it's displaying one of the 2 column names in the database (i.e., mem_suppliers). Ryan
  14. Sorry, I'm confused as to where I need to add this code or what it needs to replace. I apologize for being such a newbie! Ryan
  15. I like the concept and I believe you're onto something. However, when I run the code, it just outputs 'Array' instead of the name. Ryan echo"<pre>";print_r($field_names);
  16. Hello, I've got an array of mysql field names and I need to create a subset of these array elements (see code below). I would like to extract all of the array elements that begin with 'mem_' as these are the columns in the table that specify information pertaining to members. I presume there is a very easy way to accomplish this, but I'm currently at a loss. Thanks for your help in advance. Ryan $field_names = array(); $cols = mysql_query("SHOW COLUMNS FROM `map`"); for($i=0; $i<mysql_num_rows($cols); $i++){ array_push($field_names,mysql_result($cols, $i)); }
  17. Alright, I finally figured it out. The error was due to 1 too many elements being in the array. All I did was change for (var i=0; i<=markers.length; i++) { ... } to for (var i=0; i<markers.length; i++) { ... } Thanks for the advice! Ryan
  18. Well, I used the following code to alert the array: for (var i=0; i<=markers.length; i++) { alert(markers[i]); } and the output can be seen at http://www.indianasheep.com/pages/map.php. Obviously the array is not working, but I'm unable to figure out where it's going wrong. Ryan
  19. Dj Kat, Thanks for the reply and I apologize for my delay (it's the holidays). I see the error you are referring to (markers is undefined, but I'm still unable to figure out why, exactly, this is the case. I used your suggestion and added the backslash to the scripts/markers.php but this didn't help. What is confusing me is the fact that right now, all the markers are shown on the map with the correct colors. So it appears that everything is working. Moreover, when you click on a map marker, it brings up information that was stored in the markers[] array, so I'm just lost. Any more advice as to what is going on here? As always, thanks! Ryan
  20. Hi, I believe the error I'm receiving is JS related (though it may be php-related). Here is the page that I'm receiving the error on: http://www.indianasheep.com/pages/map.php The error is 'null' is null or not an object and it occurs whether you click on "Show All" or one of the other Member Types. Any suggestions? Ryan
  21. Thanks for the response. If the result is already returned as an array, how can I use that array to create another array? I want to use something like: $mem_type_check = array_slice(whateverthearrayiscalled,2,count(mem_type)+2); Ryan
  22. Hello, I can't seem to figure out how to check a particular subset of array values obtained by using the following statement: while(list($id, $member, $mem_producer, $mem_supplier, $firstname, $lastname) = mysql_fetch_array($resultType)) I would like to use a loop to check and see whether $mem_producer, $mem_supplier, and more categories to come are set to 'y' or 'n'. Does the while(list...) statement write the mysql values to an array? If so, what is the name of that array and can I grab a subset of it? Your help is much appreciated. Thanks, Ryan
  23. That fixed it! I knew it would be something small like that. Ryan
  24. Hello everyone. I'm writing a quick app to display rss news feeds on a website (see this page: http://www.indianasheep.com/pages/news.php). The premise here is that I read rss addresses from a text file (rssfeeds.txt), feed them into a third party app that parses the addresses (FeedForAll, rss2html.php), and display only those news items that contain keywords (also read in from a text file, keywords.txt). The output formatting is all controlled by another file (output.php). Ok, with all that being said, my issue is as follows. On my news page (http://www.indianasheep.com/pages/news.php), it keeps displaying the number '1' after each rss channel (after each table). I CANNOT figure out why this '1' is being output! Here is all the relevant code: news.php, the code that displays the news page: <?php $filename = "/home/indiana/public_html/scripts/rss/rssfeeds.txt"; $fp = @fopen($filename, 'rb'); if ($fp) { $rssfeeds = explode("\n", fread($fp, filesize($filename))); } foreach ($rssfeeds as $a) { echo include ("http://www.indianasheep.com/scripts/rss/rss2html.php?TEMPLATE=output.php&XMLFILE=".$a."&MAXITEMS=10")."<br><br>"; } ?> output.php, file used to format the rss news feeds <table width="600"> <tr><td> <table bgcolor="#666666" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="26" height="28"><img src="images/tl.png" width="26" height="28" border="0"></td> <td rowspan="2" align="center" width="548"><a href="~~~FeedLink~~~" style="text-decoration:none;" target="_blank"><h3 style="color:#FFF; padding:5px;">~~~FeedTitle~~~</h3></a></td> <td width="26" height="28"><img src="images/tr.png" width="26" height="28" border="0"></td> </tr> <tr> <td width="26" height="30"><img src="images/bl.png" width="26" height="30" border="0"></td> <td width="26" height="30"><img src="images/br.png" width="26" height="30" border="0"></td> </tr> </table> </td></tr> ~~~BeginItemsRecord~~~ <?php $okayToDisplay = 0; $file_key = 'keywords.txt'; $keywords = file($file_key); foreach ($keywords as $a) { if ((stristr("~~~ItemTitle~~~", $a) !== FALSE) || (stristr("~~~ItemDescription~~~", $a) !== FALSE)) { $okayToDisplay = 1; } } if ($okayToDisplay == 1) { ?> <tr><td><br>~~~ItemPubLongDate~~~</td></tr> <tr><td><p style="padding-left:25pt; font-weight:bold;"><a href="~~~ItemLink~~~" target="_blank">~~~ItemTitle~~~</a></p></td></tr> <?php } ?> ~~~EndItemsRecord~~~ </table> I just need to figure out why those ones keep showing up. Your help is desperately need and greatly appreciated. Thanks! Ryan
  25. Yes, globals are turn on. I know this because all of the other functions I've written also use globals.
×
×
  • 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.