jarvis
Members-
Posts
543 -
Joined
-
Last visited
Everything posted by jarvis
-
Hi All, Thanks everyone for the help so far, it's been great. I've one final query I can't seem to work out. Here's my tabel structure: wp_bp_groups id | name 1 | Aerosols 2 | Boats 3 | Boilers wp_bp_groups_members id | groupd_id | user_id 1 | 1 | 1 2 | 2 | 2 wp_bp_xprofile_data id | field_id | user_id | value 1 | 1 | 1 | john smith 2 | 2 | 1 | [email protected] 3 | 3 | 1 | 123456 4 | 1 | 2 | joe bloggs 5 | 2 | 2 | [email protected] 6 | 3 | 2 | 987564 What I want to get is: Aerosols John Smith, [email protected], 123456 Boats Joe Bloggs, [email protected], 987654 I'm at a complete loss with this one. :'( TIA if you can help in any way!
-
Thank you suresh_kamrushi , that worked like a charm! Unbelievable, I've spent all weekend trying to solve this, I never knew you could do something so simple! Cheers & a HUGE thank you!
-
Hi Pikachu2000 That could work but I'm not too sure how i'd go about doing it. Are you able to assist? Thansk
-
Thanks Pikachu2000 for the reply. Sadly I'm confined to what's already in place, it's certainly not the way I would have structured it either. I guess the only other way would be pass it to a php array & then explode it out?
-
Hi, I have a structure like so: id | field_id | user_id | value 1 | 1 | 1 | fred smith 2 | 2 | 1 | [email protected] 3 | 3 | 1 | 123456 4 | 1 | 1 | joe bloggs 5 | 2 | 1 | [email protected] 6 | 3 | 1 | 987654 What I'd like to do is return a query like this: fred Smith | [email protected] | 123456 joe bloggs | [email protected] | 987654 I'm just stumped how to do it! Any help is much appreciated. TIA
-
As a thought, would I need to return each query on its own? i.e field_id,1, field_id=2 etc? However, how could I get them to line up in a CSV?
-
Hi, Am having a total brain melt down on a php/mysql export script. I've a table wp_bp_xprofile_data with this sort of layout: ID field_id user_id value It shows data like so: id | field_id | user_id | value 1 | 1 | 1| John Smith 2 | 2 | 1 |[email protected] 3 | 3 | 1 |23 arcacia avenue 4 | 1 | 2 |Fred Smith 5 | 2 | 2 |[email protected] 6 | 3 | 2 |999 lets be avenue field_id joins to another table wp_bp_xprofile_fields, where it has id name This shows data like so: id | name 1 | Name 2 | Email 3 | Address What I need to do, is export the data to a csv so the CSV will then show: Name | Email | Address John Smith | [email protected] | 23 arcacia avenue Fred Smith | [email protected] | 999 lets be avenue However, mine keeps coming back Name | Email | Address John Smith [email protected] 23 arcacia avenue Fred Smith [email protected] 999 lets be avenue Here's my code: header ("Content-Disposition:\"inline; filename=export.csv"); header ("Content-type: text/csv\""); $query = "SELECT VALUE FROM `wp_bp_xprofile_data` ORDER BY `wp_bp_xprofile_data`.`user_id` ASC"; $result = mysql_query($query) or die("Query failed : " . mysql_error()); echo "email,telephone,county,town,add 2,add 1,company name,name,acc type,date joined,country\r\n"; //header while($row = mysql_fetch_row($result)){ echo "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$row[7],$row[8],$row[9],$row[10],$row[11]\r\n"; //data echo "$row[]\r\n"; //data } [code=php:0] Where am I going wrong? TIA
-
Thanks GalaxyTramp I did look at that but couldnt get much sense out of it - must be a bit thick! Would rather try and code something myself ideally, easier in future to alter it etc
-
Thanks salathe, I'm more than happy to bin what's there. What I'd like is a simple script I can enter the RSS URL, set it to show X number of posts (newest first), set the number of words/chars and hey presto. If you know of a simple script, I'm all eyes! Thanks
-
Hi, I've been passed the below code which converts rss to php and then displays HTML. It works well. However, I've 2 issues with it: 1) I'd like to set it so only say 5 posts are shown 2) How can I truncate the description, so it only shows say 100 chars or 20 words? Any help is much appreciated. Here's the code: <?php // DO NOT EDIT BELOW THIS LINE date_default_timezone_set("GMT"); $itemArray = array(); if($text = preg_replace("/[\t\r\n]/", " ", htmlentities(@file_get_contents($rss_feed_url), ENT_QUOTES))) { while(strpos($text, "â") == true) { $text = substr($text, 0, strpos($text, "â")) ."'". substr($text, strpos($text, "â")+9, strlen($text)); } $items = explode("<item>", html_entity_decode($text)); foreach($items as $item) { $title = ""; $link = ""; $desc = ""; $pubdate = ""; $image = ""; $item = html_entity_decode($item, ENT_QUOTES); $item = preg_replace('/&(?!amp;|quot;|nbsp;|gt;|lt;|laquo;|raquo;|copy;|reg;|bul;|rsquo;|mdash;|#)/', '&', $item); $item = str_replace("<![CDATA[","", $item); $item = str_replace("]]>","", $item); if(stripos($item, "</item>") == true) { if(preg_match('|<title>(.*)</title>|', $item, $match)) { $title = $match[1]; } if(preg_match('|<pubDate>(.*)</pubDate>|', $item, $match)) { $pubdate = strtotime($match[1]); } if(preg_match('|url="(.*)|', $item, $match)) { $search = $match[1]; $imageArray = explode('"', $search); $image = $imageArray[0]; } if(preg_match('|<description>(.*)</description>|', $item, $match)) { $desc = $match[1]; $desc = strip_tags($desc); } if(preg_match('|<link>(.*)</link>|', $item, $match)) { $link = $match[1]; $link = end(explode("*", $link)); } if($title && $link && $desc) { array_push($itemArray, "$pubdate|$title|$link|$desc|$image|"); } } } } else { print "<p>Whoops! We could not connect to: <a href=\"$rss_feed_url\">$rss_feed_url</a></p>"; } if(sort($itemArray)) { foreach(array_reverse($itemArray) as $iA) { list($pubdate,$title,$link,$desc,$image) = explode("|", $iA); $timenow = time(); $difference = $timenow-$pubdate; $days = 0; $hours = 0; $minutes = 0; print "<p>"; if($hotlink_images && $image) { if($open_links_in_new_window) { print "<a class=\"thumb\" href=\"$link\" onclick=\"openInNewWindow('$link'); return false\">" . "<img src=\"$image\" alt=\"$title\"></a>"; } else { print "<a class=\"thumb\" href=\"$link\"><img src=\"$image\" alt=\"$title\"></a>"; } } if($open_links_in_new_window) { print "<a href=\"$link\" onclick=\"openInNewWindow('$link'); return false\">$title</a><br>"; } else { print "<a href=\"$link\">$title</a><br>"; } if($pubdate) { print "<span class=\"sub\">Posted "; if(sprintf("%01.0d", $difference/(60*60*24))) { $days = sprintf("%01.0d", $difference/(60*60*24)); $difference -= $days*(60*60*24); if($days > 1) { print "$days days "; } else { print "$days day "; } } if(!(sprintf("%01.0d", $difference/(60*60*24))) && sprintf("%01.0d", $difference/(60*60))) { $hours = sprintf("%01.0d", $difference/(60*60)); $difference -= $hours*(60*60); if($hours > 1) { print "$hours hours "; } else { print "$hours hour "; } } if(!(sprintf("%01.0d", $difference/(60*60*24))) && sprintf("%01.0d", $difference/60)) { $minutes = sprintf("%01.0d", $difference/60); if($minutes > 1) { print "$minutes minutes "; } else { print "$minutes minute "; } } print "ago</span><br>"; } print "$desc</p>\n<div class=\"hr\"> </div>\n"; } } ?> Thanks again
-
So does this mean it's possible?
-
The whole block of code is <?php $i = 0; ?> <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> <?php if ( bp_get_group_status() == ('public' || 'private')) { ?> <li class="reg_groups_item"> <input type="checkbox" id="field_reg_groups_<?php echo $i; ?>" name="field_reg_groups[]" value="<?php bp_group_id(); ?>" /><?php bp_group_name(); ?> </li> <?php } ?> <?php $i++; ?> <?php endwhile; /* endif; */ ?> <?php else: ?> <p class="reg_groups_none">No selections are available at this time.</p> <?php endif; ?> it does the job
-
Hi All, I've a loop which lists a series of options as checkboxes. What I'd like to do is set 1 as a default. But I've no idea how to do it!? Here's the code: <?php $i = 0; ?> <?php if ( bp_has_groups() ) : while ( bp_groups() ) : bp_the_group(); ?> <input type="checkbox" id="field_reg_groups_<?php echo $i; ?>" name="field_reg_groups[]" value="<?php bp_group_id(); ?>" /><?php bp_group_name(); ?> <?php } ?> <?php $i++; ?> Any help is much appreciated TIA
-
Hi, Hope some one can help. Got the following code from buddypress: <?php do_action( 'bp_before_activate_content' ) ?> <?php if ( isset( $_GET['e'] ) ) : ?> <p><?php _e( 'Your account was activated successfully! Your account details have been sent to you in a separate email.', 'buddypress' ) ?></p> <?php else : ?> <p><?php _e( 'Your account was activated successfully! You can now log in with the username and password you provided when you signed up.', 'buddypress' ) ?></p> <?php endif; ?> What I'd like to do is send an email to the user once the account is activated containing the username and password as a reminder. I've tried messing around with the above to no avail, it errors due to interru[tion on the if else statement for some odd reason. Any ideas on how best to achieve this? Many thanks
-
Hi All, Hope someone can help. I've got the following code to list my comments: <?php if ( have_comments() ) : ?> <p> </p> <?php foreach ($comments as $comment) : ?> <h3><?php comment_type(_x('Review', 'noun'), __('Trackback'), __('Pingback')); ?> <?php _e('by'); ?> <?php comment_author_link() ?></h3> <p><?php comment_text() ?></p> <p class="date"><?php comment_date() ?> </p> <hr /> <?php endforeach; ?> <?php else : // If there are no comments yet ?> <p><?php _e('There are currently no reviews. Why not be the first?'); ?></p> <?php endif; ?> What I'd like to do is add pagination, say 10 comments per page. How can I do this? Thank you so much
-
Ah I see. Thanks, so I move the redirects into the htaccess file and then create an error page Thanks Thanks
-
Should I remove the stuff in my 301.php file apart from the error, then add this to my htaccess: redirect 301 /test.htm http://www.domain.com/index.htm Repeating that for each entry I need. If so, shall I add it below: ErrorDocument 404 /301.php Or does it need to go at the end of the htaccess file, i.e. after </Limit> Thanks
-
Failing that, how do I alter my .htaccess file? It currently has: # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* ErrorDocument 404 /301.php <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> Thanks
-
Hi neil.johnson Yes, I'm redirecting old URLS to new ones. As there were so many, I opted for a 301.php file which listed the files old -> new. This also allowed me to display a page not found option. As the site admin configured the server to use this as the 404. Therefore, it in essessence should redirect or show the error I believe. using the tool it shows: Checked link: http://www.domain.com/tes.htm Type of redirect: 301 Moved Permanently Redirected to: http://www.domain.com/index.htm So it looks right!? Rather than using the .htaccess file, is there a simple way to alter my PHP code not to handle the double redirect? Thanks
-
Oh I see, so my code is at fault - nadgers! What do I need to do to my code? It's a little above me :-(
-
Hi All, Not sure if this is the right forum or not, so here goes! Just trying to generate a sitemap using: http://www.sitemapdoc.com/Default.aspx but get the error: I've a 301.php redirect file on my site to handle redirects and contains: if (isset($map[$_SERVER['REDIRECT_URL']])) { $new_loc = 'http://' . $_SERVER['HTTP_HOST'] . $map[$_SERVER['REDIRECT_URL']]; if (isset($_SERVER['REDIRECT_QUERY_STRING'])) { $new_loc .= '?' . $_SERVER['REDIRECT_QUERY_STRING']; } header("HTTP/1.1 301 Moved Permanently"); header("Location: $new_loc"); } else { header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$_SERVER['HTTP_HOST']); } Is it an issue with my 301 causing the above error or something else? Many thanks
-
Hi All, I hope someone can help. I've got the following code in my index.php file to sort the posts by date d/m/y then title. <?php $posts = query_posts( $query_string . 'meta_key=Day&meta_key=Month&meta_key=Year&order=asc' ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <!-- listings_wrapper --> <div id="listings_wrapper"> <!-- listings_content --> <div id="listings_content"> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <p><?php $key="Venue"; echo get_post_meta($post->ID, $key, true); ?></p> <p><span><?php $key="Date"; echo get_post_meta($post->ID, $key, true); ?></span></p> <p><a href="<?php the_permalink() ?>">more info</a></p> </div> <!-- /listings_wrapper_content --> <!-- listings_thumbnail --> <div id="listings_thumbnail"> <?php the_post_thumbnail( 'listings-post-thumbnail' ); ?> </div> <!-- /listings_wrapper_thumbnail --> </div> <!-- /listings_wrapper --> <?php endforeach; ?> <?php else: ?> <p><?php _e('Sorry, no events matched your criteria.'); ?></p> <?php endif; ?> This works well. I'd also like this to work on my archive.php file to replace: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <!-- listings_wrapper --> <div id="listings_wrapper"> <!-- listings_content --> <div id="listings_content"> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <p><?php $key="Venue"; echo get_post_meta($post->ID, $key, true); ?></p> <p><span><?php $key="Date"; echo get_post_meta($post->ID, $key, true); ?></span></p> <p><a href="<?php the_permalink() ?>">more info</a></p> </div> <!-- /listings_wrapper_content --> <!-- listings_thumbnail --> <div id="listings_thumbnail"> <?php the_post_thumbnail( 'listings-post-thumbnail' ); ?> </div> <!-- /listings_wrapper_thumbnail --> </div> <!-- /listings_wrapper --> <?php endwhile; else: ?> <p><?php _e('Sorry, no events matched your criteria.'); ?></p> <?php endif; ?> However, when i do that and search by category, it just returns nothing. As soon as I put the code back, it works but not displaying any order, it just shows the posts. The category list is generated from: <?php wp_list_categories( 'hide_empty=0&order=ASC&title_li&exclude=3,8' ); ?> What am I doing wrong? TIA
-
Wordpress Permalinks - getting info from the url to a page
jarvis replied to jarvis's topic in Applications
Odd as that's definetely the url. Regardless of ep or not, is it possible to get those values in the URL? I would normally use something like: $pageURL=''; $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; $filename = basename($pageURL); echo $filename; But all that does is show the last part, in the above example 04. Hmmm... -
Hi All, I've a URL on my wordpress site which looks like: http://www.mydomain.com/2010/09/04/ What I'd like to do is get the 2010/09/04/ from the URL and place it into my page as follows: 04 September 2010 Any ideas how I can achieve this? TIA
-
thanks tomtimms that did the job nicely! Sometimes, things can be so simple, you just need the know how!