开发者

Trying to echo a simple money math statement that adds $5 value to every recordset that = "30"?

I have a database/store and here is my simple query :

$query_Recordset1 = "SELECT * FROM orders WHERE products = 30";

Now, we want LIVE results of how much total money we donate when people by this product. This product is around $30 dollars (which is irrelevant) but we donate $5 for every purchase to a certain cause and would l开发者_如何学Goike to show the total amount in dollars:

Like this: We have donated $755 to this cause or something like that!!

Anyways, here is my php. We need a $start variable, which is how much money we have donated before we implemented the database and store..

Here it is. I need a little help to get this to work out: Thanks in advance:

<?php 
  $start = 20; // how much money we started with before the database
  $limit = $start + $totalRows_Recordset1 + 5; // what we started with + the total number of rows that equal the product '30'


  echo $limit; 

?>


Is this what you're looking for?

<?php 
  $query_Recordset1 = mysql_query("SELECT * FROM orders WHERE products = 30");
  $num_rows = mysql_num_rows($query_Recordset1);

  $start = 20; // how much money we started with before the database
  $limit = $start + ($num_rows * 5); // what we started with + the total number of rows that equal the product '30'

  echo $limit; 

?>


Why not just change your SQL statement to get the value you're looking for?

SELECT (Count(*) * 5) + 20 FROM orders WHERE products = 30;


<?php 
  $start = 20; // how much money we started with before the database
  $totalRows_Recordset1 = mysql_num_rows($RecordSet1);
  $limit = $start + $totalRows_Recordset1 * 5; // what we started with + the total number of rows that equal the product '30'

  echo $limit; 

?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜