dimanche 19 avril 2015

Group by not showing all the rows

I am working in wordpress and below is my select query. I have used leftjoin and group by. But only one row is returned if I have duplicate entries in my articles.username coloumn. So I want all the rows to be returned with group by and duplicates should be allowed in username field. PHP Code



$sqll = "SELECT articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title, Sum(zvotes.zvotes) AS votessum FROM articles LEFT JOIN zvotes on articles.aid=zvotes.aid GROUP BY articles.competition HAVING articles.category = '$cat' && articles.competition = '$comp' ORDER BY votessum";

$results = $wpdb->get_results($wpdb->prepare($sqll)) or die(mysql_error());


Thanks


MAMP not connecting to localhost

Just updated MAMP to version 3.2.1 on Yosemite. Both Apache and MySQL servers are green but when I go to my localhost I keep getting: This webpage is not available ERR_NAME_NOT_RESOLVED in browser (Chrome). I’ve tried incognito browsing and Firefox with the same result, tried both the MAMP default port settings and ports 80 & 3306, tried a reinstall of MAMP and rolling back to previous install of MAMP; all without success.


Can anyone suggest how to fix this…it’s starting to drive me crazy!


How to use jquery in WordPress page

How could I make this code to work in a WordPress page?





<!DOCTYPE html>
<html>
<head>
<script src="http://ift.tt/1xDNnh9"></script>

<script>

jQuery(document).ready(function($) {
$("a").click(function(){

$('#versie').text('Welkom '+ $(this).attr('data-name'));
});
});
</script>

</head>

<body>

<div id="div1"><h2>Selecteer de gewenste versie: <span id="versie"></span></h2></div>

<a href="#" data-name="2007">2007</a> | <a data-name="2010" href="#">2010</a> | <a data-name="2013" href="#">2013</a>

</body>
</html>



How to setup godaddy's domain with elastic beanstalk

This has been asked several times over stackoverflow and i have been searching other websites as well but there is no proper step by step demonstration of how to achieve this. Many users are having difficulties understanding it.


It would be really great if someone could post an answer with exact steps on how to achieve this (screenshots would be great).


Thanks


How to implement pagination on a custom WP_Query Ajax

I want to paginate my WordPress posts in a custom loop with Ajax, so when I click on load more button posts will appear.


My code:



<?php
$postsPerPage = 3;
$args = array(
'post_type' => 'post',
'posts_per_page' => $postsPerPage,
'cat' => 1
);
$loop = new WP_Query($args);

while ($loop->have_posts()) : $loop->the_post();
?>
<h1><?php the_title(); ?></h1>
<p>
<?php the_content(); ?>
</p>
<?php
endwhile;
echo '<a href="#">Load More</a>';
wp_reset_postdata();
?>


This code does not paginate. Is there a better way to do this?


Mailchimp failing to get LeadPages subscription

I'm creating a LeadBox and would like the subscription details to populate my MailChimp List. The API appears to be working (e.g. the leadbox > integration settings dropdown populates with my MailChimp list), the leadbox appears to be working fine, but my mailchimp list fails to get the subscription. What am I missing?


many thanks


Adding confirm step to button in Wordpress php file

I'm using a Wordpress plugin (Work The Flow) that allows file uploads / downloads / deletion etc.


The plugin allows a user to delete any file of theirs, but doesn't ask you to confirm you really want to delete it: it just immediately deletes the file.


I'd like to add in something to ensure a confirmation popup appears first.


The plugin owner pointed me to this php code in his plugin (and specifically towards btn btn-danger delete:



function getDownloadJSTemplate() {
$script = <<<DOWNLOADJSTEMPLATE
<!-- The template to display files available for download -->
<script id="template-download" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-download fade">
<td>
<span class="preview">
{% if (file.thumbnailUrl) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" data-gallery><img src="{%=file.thumbnailUrl%}"></a>
{% } %}
</span>
</td>
<td>
<p class="name">
{% if (file.url) { %}
<a href="{%=file.url%}" title="{%=file.name%}" download="{%=file.name%}" {%=file.thumbnailUrl?'data-gallery':''%}>{%=file.name%}</a>
{% } else { %}
<span>{%=file.name%}</span>
{% } %}
</p>
{% if (file.error) { %}
<div><span class="label label-danger">Error</span> {%=file.error%}</div>
{% } %}
</td>
<td>
<span class="size">{%=o.formatFileSize(file.size)%}</span>
</td>
<td>
{% if (file.deleteUrl) { %}
<button class="btn btn-danger delete" data-type="{%=file.deleteType%}" data-url="{%=file.deleteUrl%}&action=load_ajax_function"{% if (file.deleteWithCredentials) { %} data-xhr-fields='{"withCredentials":true}'{% } %}>
<i class="glyphicon glyphicon-trash"></i>
<span>Delete</span>
</button>
<input type="checkbox" name="delete" value="1" class="toggle">
{% } else { %}
<button class="btn btn-warning cancel">
<i class="glyphicon glyphicon-ban-circle"></i>
<span>Cancel</span>
</button>
{% } %}
</td>
</tr>
{% } %}
</script>
DOWNLOADJSTEMPLATE;
return $script;
}


Can anyone advise - assuming I can create a child .php file to do this? - how I can add a confirmation stage in? The delete button can appear many times on the page, as it appears alongside each uploaded file.