A
Anonymous
Guest
i have to tables, 1 store cutomer detail and the 2nd store buy info as follow:
table customer:
name
table buy_info:
buy_id
name
total
Now i have to calculate the grand total of buy_info for each customer.
i try in php code:
$result1=mysql_query("SELECT name FROM customer");
while($row1=mysql_fetch_row($result1)){
$result2=mysql_query("SELECT SUM(total) FROM buy_info WHERE name=$row1['name']");
}
then i will get the list of name with grand total calculated,
but the problem is when my customer are more, my scripts run very slow (more than a minutes) even it works
Is there anything not suitable in my script or how to speed up the script.
could someone help.thanks.
table customer:
name
table buy_info:
buy_id
name
total
Now i have to calculate the grand total of buy_info for each customer.
i try in php code:
$result1=mysql_query("SELECT name FROM customer");
while($row1=mysql_fetch_row($result1)){
$result2=mysql_query("SELECT SUM(total) FROM buy_info WHERE name=$row1['name']");
}
then i will get the list of name with grand total calculated,
but the problem is when my customer are more, my scripts run very slow (more than a minutes) even it works
Is there anything not suitable in my script or how to speed up the script.
could someone help.thanks.