Jump to content

SELECT..AS problem in PHP


zoomboom

Recommended Posts

Hello,

 

I am trying to do some calculations on the select stament and assigning the result to a different name.

 

Here's the problem, I need to calculate the customers points based on sales value, items and recommendations.

 

When I do SELECT int(value*items+recommendations) as points from MySQL I get the correct answer

 

However, when I do this in PHP then points is always set to NULL. I don't know why.

 

Any help appreciated!

Link to comment
https://forums.phpfreaks.com/topic/111302-selectas-problem-in-php/
Share on other sites

Here's the part that gets the values from the database:

 

$sql="SELECT int(value*items+recommend) as points from customers order by points desc LIMIT 30";

 

$rs = $conn->Execute($sql);

 

if($rs->recordcount()>0){$answers = $rs->getrows();}

 

When I run the SQL directly on MySQL it works. I get results like:

 

points

5679

4456

2345

etc...

 

whereas when I run this in php I get a NULL for points

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.