Need help with a poll

This is a discussion on "Need help with a poll" within the PHP Forum section. This forum, and the thread "Need help with a poll are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 6th, 2007, 01:13
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Need help with a poll

This is some really old code that I found somewhere so I know it's VERY sloppy but it works ... well ... almost

The bit that doesn't work is the part that loops through the number of votes for each option

Here's the code for that section

PHP: Select all

<?
        $show_votes 
mysql_query("select * from pollq where pollq_id='$pollq_id'");
        while(
$row_show_votes mysql_fetch_array($show_votes)) {
            for(
$j 1$j <= 10$j++) { 
                if(
$row_show_votes['rep'.$j] != "") { ?>
                    <tr>
                        <td width="40" style="padding-left: 10px;" height="21"><? echo $row_show_votes['rep'.$j] . " <strong>[" number_format(($answertally[$j-1] / $answertotal) * 1000"."'') . "%]</strong>" " "?></td>
                        <td width="90" style="padding-left: 10px;" height="21" valign="middle"><img src="/i/line.jpg" width="<? echo ($answertally[$j-1] / $answertotal) * 50?>" height="10"></td> 
                    </tr>
                <? }
            }
?>
            </table>
            <p><strong><?=$answertotal?> votes</strong></p>
    <?     ?>

And this is the part that doesn't work
PHP: Select all

<? echo $row_show_votes['rep'.$j] . " <strong>[" number_format(($answertally[$j-1] / $answertotal) * 1000"."'') . "%]</strong>" " "?>

Actually ... the first bit $row_show_votes['rep'.$j] works but the number_format things doesn't

Same with this part that doesn't work

PHP: Select all

<img src="/i/line.jpg" width="<? echo ($answertally[$j-1] / $answertotal) * 50?>" height="10">
Reply With Quote

  #2 (permalink)  
Old Oct 6th, 2007, 04:12
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help with a poll

Hi Karinne,

I think this may work for both.

The first part that doesn't work

PHP: Select all

<? echo $row_show_votes['rep'.$j] . " <strong>[" floor(($answertally[$j-1] / $answertotal) * 100) . "%]</strong>" " "?>

You had number format set up to have no decimal places (with no other formatting) so if you just round down, you get the same result.

Then change the next part to be:

PHP: Select all



<img src="/i/line.jpg" width="<? echo floor(($answertally[$j-1] / $answertotal) * 50); ?>" height="10">
Because the width of an image cannot be a floating point number, you round it down as well.

Hope that helps,

Rakuli.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 6th, 2007, 12:07
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help with a poll

That didn't work. It still returns 0 in both cases.

EDIT: Nevermind... I just noticed in my DB that's it's not catching the answer when I vote DUH!
Reply With Quote
  #4 (permalink)  
Old Oct 6th, 2007, 12:12
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help with a poll

Alright ... it works now. I hate it when I have these "blond" moments
Reply With Quote
  #5 (permalink)  
Old Oct 6th, 2007, 12:17
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Need help with a poll

Lol, I think they're called "human" moments
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
[poll] Which is the best 360 game? CloudedVision Webforumz Cafe 4 May 22nd, 2008 10:17
Poll? Jack Franklin PHP Forum 4 Jan 5th, 2008 10:10
Poll robukni PHP Forum 1 Apr 12th, 2007 13:39
Image Poll Help errant PHP Forum 3 Jan 4th, 2007 14:36
Flash Poll JacobHaug Flash & Multimedia Forum 12 Sep 6th, 2006 13:39


All times are GMT. The time now is 07:25.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43