views:

55

answers:

3

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?

+5  A: 

30% of any value is that value multiplied by 0.3. So 30% of 30% is 30 * 30 / 100 or 9%.

Substitute in whatever numbers you desire.

paxdiablo
I don't know why I didn't think of that. I was racking my brain all night trying to figure it out
Rob
+1  A: 

Multiplication?

.3 * $_GET['percentage'] / 100.0
Matthew Flaschen
A: 

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.

Kendall Hopkins