This is a discussion on "displaying information as a percentage?" within the PHP Forum section. This forum, and the thread "displaying information as a percentage? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
displaying information as a percentage?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
displaying information as a percentage?
I am attempting to display information submitted to a database byway of checkboxes, as a percentage of the rows within that database.
So for example; if a checkbox for ‘Group1’ was ticked once while submitting 4 separate entries to the database, ‘Group1’ would then be displayed as 25% of that database. Does anyone know how I would submit this information to the database via checkboxes and inturn, display that information as a percentage of that database? I have managed to submit the information to the database. But my query for extracting it as a percentage is constantly displayed as a error message. :( |
|
|
|
|||
|
Re: displaying information as a percentage?
Simpler to query for the totals of each 'group' and then do the calculations via php on the results. The simpler your query, the faster are your results.
That's my 2 cents :^{> |
|
||||
|
Re: displaying information as a percentage?
Can you post your PHP code that is giving you the errors?
It shouldn't be too hard to do what you need. Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: displaying information as a percentage?
Thanks for the response.
The following is the checkbox code for my php form which submits the information to the database fine: ..., </tr> <tr> <td><p><b>Mentoring and Coaching:</b></p></td> <td><p><input type="checkbox" name="mc1" value="1"> <?php if (isset($_POST['mc1'])) echo $_POST['mc1']; ?></p></td> </tr> <tr> <td><p><b>Accredited Training for Staff:</b></p></td> <td><p><input type="checkbox" name="sat2" value="1"> <?php if (isset($_POST['sat2'])) echo $_POST['sat2']; ?></p></td> </tr> <tr> <td><p><b>Classroom Based Training:</b></p></td> <td><p><input type="checkbox" name="cbr3" value="1"> <?php if (isset($_POST['cbr3'])) echo $_POST['cbr3']; ?></p></td> </tr> <tr> <td><p><b>Development and Delivery of Training:</b></p></td> <td><p><input type="checkbox" name="ddt4" value="1"> <?php if (isset($_POST['ddt4'])) echo $_POST['ddt4']; ?></p></td> </tr> <tr> ..., My query for extracting the code as a percentage of the database is: $query = "(SELECT * FROM yourl_titles ORDER BY Rand()*1/percentage)LIMIT 1)"; The message I receive is 'Couldn't execute query' ??????? |
|
|||
|
Re: displaying information as a percentage?
Quote:
If you cut 'n paste this line, you're missing a left parenthesis or have an unneeded right one |
|
||||
|
Re: displaying information as a percentage?
If you want to select using MySQL you have to so something like
If you want to display as a total using PHP, you need to use something like
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Document Information | ClaireB | Classic ASP | 0 | Oct 24th, 2006 17:46 |
| Erratic widths of percentage-based columns in IE | psyche | Web Page Design | 4 | Aug 13th, 2006 09:43 |
| Working out Percentage | jwalker80 | JavaScript Forum | 3 | Jun 10th, 2006 16:29 |
| Percentage problems | HOYS | Web Page Design | 7 | Jan 31st, 2006 15:37 |