Jump to content

Need help with this


tartou2

Recommended Posts

Hello again

I have now this code and for some reason it is only showing the first 2 user ids.

It echo this

1 2

 

<?php
session_start();
require '../include/connect.php';

$today_date=gmstrftime("%b %d, %Y");

$check=mysql_query("select * from members where status='active'");
while($row=mysql_fetch_array($check)) 
{
echo $member_id=$row['member_id']." ";
$username=$row['username'];
$balance=$row['balance'];
$email=$row['member_email'];
$first_name=$row['member_name'];
$last_name=$row['lastname'];

function report($member_id,$username,$balance,$email,$first_name,$last_name) 
{
$check=mysql_query("select sum(amount) as amount from deposit where member_id=$member_id and status!='not_paid'");
$row=mysql_fetch_array($check);
$total_amount_invested=$row['amount'];

$total_account_balance=$balance+$total_amount_invested;

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='intrest_earned'");
$row=mysql_fetch_array($check);
$total_interests_earned=$row['amount'];
$total_interests_earned=round($total_interests_earned,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='withdrawal'");
$row=mysql_fetch_array($check);
$total_withdrawl_amount=$row['amount'];
$total_withdrawl_amount=round($total_withdrawl_amount,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='commissions'");
$row=mysql_fetch_array($check);
$total_commission=$row['amount'];
$total_commission=round($total_commission,2);

$subject = "Weekly report";
$headers="From: Test<noreply@test.com> \r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$mmessage = "Dear $first_name $last_name,
<p />
Below, please find your current account data and interest earned for the last week.
<p />
You account name: <font color=blue>$username</font>
<br />
Current account balance: <font color=blue>$balance</font>
<br />
Invested account balance: <font color=blue>$total_amount_invested</font>
<br />
Total account balance: <font color=blue>$total_account_balance</font>
<br />
Total profit: <font color=blue>$total_interests_earned</font>
<br />
Total withdrawn: <font color=blue>$total_withdrawl_amount</font>
<br />
Total referral commision: <font color=blue>$total_commission</font>
<p />
This report was generated on $today_date
<p />
Sincerely Yours,
<p />
-----------------------------
<br />
- This is an automated message. Please do not reply for any reason.";
//mail($email, $subject, $mmessage, $headers);
}
report($member_id,$username,$balance,$email,$first_name,$last_name);
}
?>

 

This is the whole code, how to fix this problem and make all activated accounts id to show

Link to comment
Share on other sites

simple test of content

<?php
session_start();
require '../include/connect.php';
$result=mysql_query("select * from members");
while($row = mysql_fetch_array($result) {
echo $row['member_id'] . " - " $row['status'] . "<br>";
}
exit();
?>

you forgot to put a ")" at the end of the while but anyway this is what was echoed

1 - active
2 - active
3 - active
4 - active
5 - active
6 - active
7 - active
8 - active
9 - new
10 - active
122 - active
123 - active
124 - new
125 - active
126 - active
127 - active
128 - active
129 - active
130 - active
131 - active
132 - active
133 - active
134 - active
135 - active
136 - active
137 - active
138 - active
139 - active
140 - active
141 - new
142 - active
143 - active
144 - new

Link to comment
Share on other sites

just moved things around, try this...

<?php
session_start();

require '../include/connect.php';

$today_date=gmstrftime("%b %d, %Y");



/* define function here */
function report($member_id,$username,$balance,$email,$first_name,$last_name) {
$check=mysql_query("select sum(amount) as amount from deposit where member_id=$member_id and status!='not_paid'");
$row=mysql_fetch_array($check);
$total_amount_invested=$row['amount'];

$total_account_balance=$balance+$total_amount_invested;

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='intrest_earned'");
$row=mysql_fetch_array($check);
$total_interests_earned=$row['amount'];
$total_interests_earned=round($total_interests_earned,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='withdrawal'");
$row=mysql_fetch_array($check);
$total_withdrawl_amount=$row['amount'];
$total_withdrawl_amount=round($total_withdrawl_amount,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='commissions'");
$row=mysql_fetch_array($check);
$total_commission=$row['amount'];
$total_commission=round($total_commission,2);

$subject = "Weekly report";
$headers="From: Test<noreply@test.com> \r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$mmessage = "Dear $first_name $last_name,
<p />
Below, please find your current account data and interest earned for the last week.
<p />
You account name: <font color=blue>$username</font>
<br />
Current account balance: <font color=blue>$balance</font>
<br />
Invested account balance: <font color=blue>$total_amount_invested</font>
<br />
Total account balance: <font color=blue>$total_account_balance</font>
<br />
Total profit: <font color=blue>$total_interests_earned</font>
<br />
Total withdrawn: <font color=blue>$total_withdrawl_amount</font>
<br />
Total referral commision: <font color=blue>$total_commission</font>
<p />
This report was generated on $today_date
<p />
Sincerely Yours,
<p />
-----------------------------
<br />
- This is an automated message. Please do not reply for any reason.";
//mail($email, $subject, $mmessage, $headers);
}
/* END OF FUNCTION DEFINITION  */


$check=mysql_query("select * from members where status='active'");

while($row=mysql_fetch_array($check)) {
$member_id=$row['member_id'];
echo $member_id . "<br>";
$username=$row['username'];
$balance=$row['balance'];
$email=$row['member_email'];
$first_name=$row['member_name'];
$last_name=$row['lastname'];
report($member_id,$username,$balance,$email,$first_name,$last_name);
}

?>

Link to comment
Share on other sites

just moved things around, try this...

<?php
session_start();

require '../include/connect.php';

$today_date=gmstrftime("%b %d, %Y");



/* define function here */
function report($member_id,$username,$balance,$email,$first_name,$last_name) {
$check=mysql_query("select sum(amount) as amount from deposit where member_id=$member_id and status!='not_paid'");
$row=mysql_fetch_array($check);
$total_amount_invested=$row['amount'];

$total_account_balance=$balance+$total_amount_invested;

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='intrest_earned'");
$row=mysql_fetch_array($check);
$total_interests_earned=$row['amount'];
$total_interests_earned=round($total_interests_earned,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='withdrawal'");
$row=mysql_fetch_array($check);
$total_withdrawl_amount=$row['amount'];
$total_withdrawl_amount=round($total_withdrawl_amount,2);

$check=mysql_query("select sum(amount) as amount from history where user_id=$member_id and type='commissions'");
$row=mysql_fetch_array($check);
$total_commission=$row['amount'];
$total_commission=round($total_commission,2);

$subject = "Weekly report";
$headers="From: Test<noreply@test.com> \r\n";
$headers.= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers.= "MIME-Version: 1.0\r\n";
$mmessage = "Dear $first_name $last_name,
<p />
Below, please find your current account data and interest earned for the last week.
<p />
You account name: <font color=blue>$username</font>
<br />
Current account balance: <font color=blue>$balance</font>
<br />
Invested account balance: <font color=blue>$total_amount_invested</font>
<br />
Total account balance: <font color=blue>$total_account_balance</font>
<br />
Total profit: <font color=blue>$total_interests_earned</font>
<br />
Total withdrawn: <font color=blue>$total_withdrawl_amount</font>
<br />
Total referral commision: <font color=blue>$total_commission</font>
<p />
This report was generated on $today_date
<p />
Sincerely Yours,
<p />
-----------------------------
<br />
- This is an automated message. Please do not reply for any reason.";
//mail($email, $subject, $mmessage, $headers);
}
/* END OF FUNCTION DEFINITION  */


$check=mysql_query("select * from members where status='active'");

while($row=mysql_fetch_array($check)) {
$member_id=$row['member_id'];
echo $member_id . "<br>";
$username=$row['username'];
$balance=$row['balance'];
$email=$row['member_email'];
$first_name=$row['member_name'];
$last_name=$row['lastname'];
report($member_id,$username,$balance,$email,$first_name,$last_name);
}

?>

 

yeahhhh you're the man bro

The code works perfectly

Link to comment
Share on other sites

You really should look at moving allot of those queries into one. Your code is ridiculously inefficient.

 

yes i know i am not a professional with php coding but i am doing my best.

Would you mind helping me with making one queries for all those queries ? because I don't know how to do it

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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