i have this code that suppose to sum up the count from a specific
function but all i do get is different
the printed value suppose to be 8 but am get 4 4 4 4 instead
i have Tried any possible way to get it work but its difficult for me, every suggestion,ideal, recommendation is highly needed.
, please what must i do? or what am not doing
here is the Code
public function upgrade_admin_to_prime(){
//get the admins
$admin_users =$this->get_admin_user();
foreach($admin_users as $row){
$admin_username =$row['username'];
//check if my downline that is my ingress downline is upto 2
$downline_count =$this->count_if_downline_is_complete($admin_username);
if($downline_count == 2){
//get my downline user
$downline_users =$this->list_my_downline($admin_username);
foreach($downline_users as $row){
$downline_username =$row['downline_username'];
//check if user downline count is 4
//$downline_count2 ='';
$downline_count2 =$this->count_if_downline_is_complete($downline_username);
$downline_count2 =$downline_count2+$downline_count2;
if($downline_count2 == 4){
$downline_users3 == // array of 4 users 'favor','kane','samson','fish'
foreach($downline_users3 as $row){
$downline_username3 =$row['downline_username'];
$downline_count3 =2;
echo $downline_count3 =$downline_count3+$downline_count3;
if($downline_count3 == 8){
echo "Yess oo";
}else{
echo "nope";
}
}
}else{
echo '2nd Generation Downline user count is not complete yet'.br();
}
}
}else{
echo 'your count is not complete yet'.br();
}
}
}
i want this code here to Output 8 for me but its giving me 4 4 4 4
$downline_count3 =2;
echo $downline_count3 =$downline_count3+$downline_count3;
if($downline_count3 == 8){
echo "Yes oo";
}else{
echo "nope";
}
Related
I want to know how it is possible to specify on which output a function node can return a message (msg).
For example:
if( msg.eui == "00:11:22:33:44:55:66:88"){
output1(msg); //return on the output 1 only
}
if( msg.eui == "00:11:22:33:44:55:66:99"){
output2(msg); //return on the output 2 only
}
What needs to be changed?
That can be done. Node-Red uses an array of messages to address the different output ports.
if( msg.eui == "00:11:22:33:44:55:66:88"){
return [msg, null]; //return on the output 1 only
}
if( msg.eui == "00:11:22:33:44:55:66:99"){
return [null, msg]; //return on the output 2 only
}
The output that should not receive the message is set to null, the other to the return message.
What's with this PHP Parsing Error Unexpected '{', expecting '('
No backtrace, no any other error message, just one line in the controller, that's it -_-
I kept looking for solutions and reading many links related to this.
What could be the reason for the error in my code below..
This was my controller code (which was working fine):
if (isset($filter) && !empty($search)) {
$data['users'] = $this->model_search->searchTutor($field, $search);
}
elseif (($filter == 'subjName') && !empty($search)) {
$data['users'] = $this->model_search->searchBySubj($field, $search);
}
else {
$data['users'] = $this->model_search->getlist($field);
}
//later i wanted to add a code that will show No Result Found
The view file of my page started giving this error when I added an elseif statement in my controller (Search.php):
if (isset($filter) && !empty($search)) {
$data['users'] = $this->model_search->searchTutor($field, $search);
}
elseif (($filter == 'subjName') && !empty($search)) {
$data['users'] = $this->model_search->searchBySubj($field, $search);
}
//so I added another elseif
elseif (isset($filter) && empty($search)) {
$data['users'] = $this->model_search->getlist($field);
}
//and put the No Result last
else {
$this->session->set_flashdata('nores','<div class="alert text-center">No result matched your search.</div>');
}
Is it because of the multiple elseif condition or am I really missing something here? Please help..
elseif {
Your new elseif has no condition. When do you expect it to run? You need to add a condition.
I am trying to get a total from the rows returned for the selected opportunity.
When a opportunity is selected each product they have purchased and its price is listed. I am trying to use the price for each purchased product to get a subtotal for all sales made with that opportunity.
Here is the code I have:
function total(&$focus, $event, $arguments)
{
$total = 0;
foreach ($this->bean->Product_Sales['sales_price_c'] as $entry) {
$total += unformat_number($entry['sales_price_c']);
}
$this->bean->ss->assign('total_sales_c', format_number($total));
}
Example of how rows are returned:
[Product_Name_Field] [Product_Price_Field] [Sales_Person_Field] [Etc_Field]
Only qty(1) Product sold per returned row.
What am I doing wrong?
Thanks in advance.
Okay I figured it out!!!!
This is File view.detail.php in Custom/Module/Opportunities/Views/
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.detail.php');
class OpportunitiesViewDetail extends ViewDetail {
function OpportunitiesViewDetail(){
parent::ViewDetail();
}
function display() {
$account = new Opportunity();//var = new ModuleName() in singular form
$account->retrieve($_REQUEST['record']);//This grabs the record
$contacts = $account->get_linked_beans('opportunities_op_ps_product_sales_1','Contact');
//this uses the get_linked_beans(Param 1 is the linked var name found in the vardefs ,Param 2 is the name of the object you are creating. The name can be anything you like.)
// loop through the created associations to get fields.
foreach ( $contacts as $contact ) {
$total += $contact->sales_price_c;//add the value of each sale to the variable
}
//populate the field you want with the value in the $total var
echo "
<script>
var total = '$total';
$(document).ready(function(){
$('#total_sales_c').after(total); });
</script>";
parent::display();
}
}
?>
Hopefully this will help others.
Inside my User model I would like to make a isMember function.
public function isMember()
{
return(\Auth::check() && "get the status value here" == 1)
}
I got two models. User, Club.
Their pivot table: club_user
user_id
club_id
status
The 'status' column holds 0 or 1.
Now, how do i check the value for the extra column 'status'?
Update:
It's a many-to-many relationship.
Try This:
public function isMember(){
if(\Auth::check())
return (bool) $this->status;
return false;
Well, I got it to work. If somebody got some suggestions how to make it better, please fell free.
public function isMember($clubId)
{
$user = Club::find($clubId)->user()->where('club_user.user_id', \Auth::id())->first();
if (is_object($user))
{
$status = $user->pivot->status;
else
{
$status = 0;
}
return (\Auth::user() && $status == 1);
}
I have some code to check is a form is being spammed and if so then stop the email.
It includes a section like this:
if(strpos($messagefield, " cialis") !== false){
$noemail = true;
}
if(strpos($messagefield, " viagra") !== false){
$noemail = true;
}
etc for as many words as we have in the bad word list
This works fine, but is clumsy and difficult to easily add new words to check.
It would be easier if I could create an array and check any field against the array, but I am strugling to find an example to use (most examples still specify the text to search for which defeats the object in this case)
Can anyone help with code to check $messagefield against an array?
(I know there are better ways maybe but this works for us at the moment!)
$i = 0;
$wordlist = array(' cialis', ' viagra');
while ($i < count($wordlist) && $noemail == false) {
if (strpos($messagefield, $wordlist[$i]) !== false) {
$noemail = true;
}
$i++;
}
It is better to use stripos (case-insensitive version of strpos).
Try following code:
$a = array(' cialis', ' viagra');
for ($i = 0; $i < count($a); $i++)
if(stripos($messagefield, $a[$i]) !== false){
$noemail = true;
break;
}
}