Fairly simple question:
Say I want to use 30 percent of the rows in the table of my MySQL table.
However I also have a user input where they can select a percentage of that percentage
For example: $_GET['percentage']% of 30%
so we say that $_GET['percentage'] = 30
How would I select 30% (or $_GET['percentage'])
of 30% to use in a while loop?
30% of any value is that value multiplied by 0.3.
So 30% of 30% is 0.3 * 0.3 = 0.09
, or 9%.
Substitute in whatever numbers you desire.
Multiplication?
.3 * $_GET['percentage'] / 100.0
You can use mysql_num_rows
or PDOStatement::rowCount
depending on which library your using to get the number of rows returned by the query and then simple multiplication can tell you how many times you should call mysql_fetch_row
or PDOStatement::fetch
.
精彩评论