Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-sales domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the better-click-to-tweet domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-amazon domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-stats domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Shortcodes | Problem to display variable on table wp_events_answer | Event Espresso - Staging Server

Support

Home Forums Event Espresso Premium Shortcodes | Problem to display variable on table wp_events_answer

Shortcodes | Problem to display variable on table wp_events_answer

Posted: March 18, 2014 at 8:12 pm

Viewing 2 reply threads


Hafifi Omar

March 18, 2014 at 8:12 pm

I’m trying to create shortcodes for wordpress.
I would like to display by DISTINCT from ‘answer’ but COUNT the TOTAL from ‘answer’.

If you find on foreach in my code, I have no idea how to echo the count

currently i’m using count($data->answer);

Please take a look

TABLE : wp_events_answer

??????????????????????????????????
? id ? answer ?question_id ?
??????????????????????????????????
? 1 ? Maybank ? 12 ?
? 2 ? Maybank ? 12 ?
? 3 ? Maybank ? 12 ?
? 4 ? CIMB ? 12 ?
??????????????????????????????????

My desired outcome is

??????????????????????????????????
? No ? Bank ? Total ?
??????????????????????????????????
? 1 ? Maybank ? 2 ?
? 2 ? CIMB ? 1 ?
??????????????????????????????????

My current outcome

??????????????????????????????????
? No ? Bank ? Total ?
??????????????????????????????????
? 1 ? Maybank ? 1 ?
? 2 ? Maybank ? 1 ?
? 3 ? Maybank ? 1 ?
? 4 ? CIMB ? 1 ?
??????????????????????????????????

=

$sql= ”
SELECT *, count(*)
FROM wp_events_answer
INNER JOIN wp_events_attendee ON wp_events_attendee.registration_id= wp_events_answer.registration_id
WHERE question_id=12 AND event_id=’$eventid’ GROUP by answer
“;

$datas= $wpdb->get_results($sql);
$num_rows = $wpdb->num_rows;
if ($num_rows > 0)
{
$result .= ‘<table id=”attendeeList”>
<thead>
<tr>
<th width=”10%” scope=”col”>No.</th>
<th width=”70%” scope=”col”>Group Name</th>
<th width=”20%” scope=”col”>Total</th>
</tr></thead>’;
$number = 1;

foreach ($datas as $data) {
$result .= ‘<tbody>’;
$result .= ‘<tr>’;
$result .= ‘<td>’;
$result .= $number++;
$result .= ‘</td>’;
$result .= ‘<td>’;
$result .= $data->answer;
$result .= ‘</td>’;

$result .= ‘<td>’;
$result .= count($data->answer); //i have no idea how to print total this
$result .= ‘</td>’;

$result .= ‘</tr>’;
}
$result .= ‘</table>’;

return $result;

}
else
{ return ‘There is no group’; } }


Hafifi Omar

March 18, 2014 at 8:15 pm

how to edit this post


Dean

  • Support Staff

March 19, 2014 at 5:04 am

Hi,

Large blocks of code are best linked to from a service such as Pastebin.

If you require assistance with customising the plugin, we have a list of recommended developers here – http://staging.eventespresso.com/developers/event-espresso-pros/

Viewing 2 reply threads

The support post ‘Shortcodes | Problem to display variable on table wp_events_answer’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso - Staging Server