Jump to content

jarvis

Members
  • Posts

    543
  • Joined

  • Last visited

Posts posted by jarvis

  1. Oooooh that seems to be getting somewhere. I now get:

    name | value

    aerosols | joe bloggs

    null | joe@bloggs.com

    null | 123456

     

    Oddly only shows one category? And the values list down. Changing the query to:

    SELECT wp_bp_groups.name, GROUP_CONCAT( wp_bp_xprofile_data.value SEPARATOR ',' )

    FROM wp_bp_groups

    RIGHT JOIN wp_bp_xprofile_data

    ON (wp_bp_groups.id = wp_bp_xprofile_data.user_id)

    That sorts the list values. Will give that some more testing. I think it's only returning one person and one category. However, I've several test people assigned to several cats. Will test more!! Thanks

  2. I've tried this:

    SELECT wp_bp_groups.name,  GROUP_CONCAT( wp_bp_xprofile_data.value SEPARATOR ',' )

    FROM wp_bp_xprofile_data, wp_bp_groups_members, wp_bp_groups

    WHERE wp_bp_groups.id = wp_bp_groups_members.id

    AND wp_bp_groups_members.id = wp_bp_xprofile_data.id

    Although it returns a result, it only returns a single result and not:

    Aerosols

    John Smith, john@smith.com, 123456

     

    More like:

    Aerosols John

  3. 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 | john@smith.com

    3 | 3 | 1 | 123456

    4 | 1 | 2 | joe bloggs

    5 | 2 | 2 | joe@bloggs.com

    6 | 3 | 2 | 987564

     

    What I want to get is:

     

    Aerosols

    John Smith, john@smith.com, 123456

     

    Boats

    Joe Bloggs, joe@bloggs.com, 987654

     

    I'm at a complete loss with this one.  :'(

     

    TIA if you can help in any way!

  4. 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?

  5. Hi,

     

    I have a structure like so:

     

    id | field_id | user_id | value

    1 | 1 | 1 | fred smith

    2 | 2 | 1 | fred@smith.com

    3 | 3 | 1 | 123456

    4 | 1 | 1 | joe bloggs

    5 | 2 | 1 | joe@bloggs.com

    6 | 3 | 1 | 987654

     

    What I'd like to do is return a query like this:

    fred Smith | fred@smith.com | 123456

    joe bloggs | joe@bloggs.com | 987654

     

    I'm just stumped how to do it! Any help is much appreciated.

     

    TIA

  6. 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 |john@smith.com

    3 | 3 | 1 |23 arcacia avenue

    4 | 1 | 2 |Fred Smith

    5 | 2 | 2 |fred@smith.com

    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 | john@smith.com | 23 arcacia avenue

    Fred Smith | fred@smith.com | 999 lets be avenue

     

    However, mine keeps coming back

    Name | Email | Address

    John Smith

    john@smith.com

    23 arcacia avenue

    Fred Smith

    fred@smith.com

    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

  7. 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

  8. 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

  9. 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

  10. 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

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