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<[email protected]> \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
https://forums.phpfreaks.com/topic/222938-need-help-with-this/
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();
?>

Link to comment
https://forums.phpfreaks.com/topic/222938-need-help-with-this/#findComment-1152722
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
https://forums.phpfreaks.com/topic/222938-need-help-with-this/#findComment-1152931
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<[email protected]> \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
https://forums.phpfreaks.com/topic/222938-need-help-with-this/#findComment-1152941
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<[email protected]> \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
https://forums.phpfreaks.com/topic/222938-need-help-with-this/#findComment-1152945
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
https://forums.phpfreaks.com/topic/222938-need-help-with-this/#findComment-1152952
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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