Jump to content

rndilger

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rndilger's Achievements

Member

Member (2/5)

0

Reputation

  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);
×
×
  • 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.