Is it possible to somehow calc the difference between two rows of one table?
I tried this, but it doesnt work:
$diff = mysql_num_rows("
SELECT (`used`-`paid`)
FROM `coupons_codes`
WHERE `cid`='".$data['cid']."'");
Is it possible to somehow calc the difference between two rows of one table?
I tried this, but it doesnt work:
$diff = mysql_num_rows("
SELECT (`used`-`paid`)
FROM `coupons_codes`
WHERE `cid`='".$data['cid']."'");
You should do something like this:
//store the query in a string
$query = "SELECT `used`-`paid` FROM `coupons_codes` WHERE `cid`='".$data['cid']."'";
//execute the query on the MySQL database
$result = mysql_query($query);
//extract the result from the response from the MySQL server
$diff = mysql_result($result, 0, 0);
The function you're using is used to count the number of rows in a resultset obtained from a mysql_query();
call.
I suggest you try to read up on some basics concerning PHP and MySQL, I have a feeling that you lack some basic knowledge to really create good code.