Best wishesFred."> Problem with Code in the "Fields"-Box - Forums

Forums

Problem with Code in the "Fields"-Box

Fredolino 17 Jun, 2016
Hello,

in the "front list" in the "Columns list" is "fun.funies: FUNies".
How do I change this code if the code in the "Fields-Box" is intended to:
fun.funies:
<?php
$query = "SELECT user_id, SUM(funies) FROM c9ol5_funies GROUP BY user_id"; 
	 $result = mysql_query($query) or die(mysql_error());
// Print out result
while($row = mysql_fetch_array($result)){
	echo " ". $row['user_id']. " = ". $row['SUM(funies)'];
	echo "<br />";
}
?>


Best wishes
Fred.
GreyHead 18 Jun, 2016
Hi Fred,

Sorry but I have no idea what you are trying to do here?

I'm pretty sure that you don't want to run a database query like this for each row in the listing.

You also don't want to use $row as a variable name as CC also uses that.

Bob
Fredolino 20 Jun, 2016
Hi,

My problem is only:
I have in the "Fields box" in "Models":
<?php return array("SUM(funies)" => "fun.funies"); ?>

The sum is displayed in the frontend me correctly but the other rows in the table are suddenly empty.
What is the problem?

Best wishes
Fred.
GreyHead 23 Jun, 2016
Hi Fredolino,

That looks correct, your Fields list only specifies one field so that is all that is being retrieved.

Bob
Fredolino 26 Jun, 2016
Hi Bob,

thank you very much. I could solve in the meantime. :-)

Best regards
Fred.
This topic is locked and no more replies can be posted.