website logo
Auteur
avatar
nicolas

Forum » » Demo » » pollboth.php a la racine


Posté : 09-09-2023 18:11 icone du post

[code php]
function pollResults(int $pollID): void  
{
   global $NPDS_Prefix, $maxOptions, $setCookies;

   if (!isset($pollID) OR empty($pollID)) $pollID = 1;
   $result = sql_query("SELECT pollID, pollTitle, timeStamp FROM ".$NPDS_Prefix."poll_desc WHERE pollID='$pollID'");
      list(,$pollTitle) = sql_fetch_row($result);

   echo '
   

'.$pollTitle.'

'; $result = sql_query("SELECT SUM(optionCount) AS SUM FROM ".$NPDS_Prefix."poll_data WHERE pollID='$pollID'"); list($sum) = sql_fetch_row($result); echo '

'.$sum.' '.translate("Résultats").'

'; for ($i = 1; $i <= $maxOptions; $i++) { $result = sql_query("SELECT optionText, optionCount, voteID FROM ".$NPDS_Prefix."poll_data WHERE (pollID='$pollID') AND (voteID='$i')"); $object = sql_fetch_assoc($result); // php8 if (!is_null($object)) { $optionText = $object['optionText']; $optionCount = $object['optionCount']; } else { $optionText = ''; $optionCount = 0; } // php8 if ($optionText!= "") { if ($sum) { $percent = 100*$optionCount/$sum; $percentInt = (int)$percent; } else { $percentInt = 0; } echo '
'.aff_langue($optionText).'
'.wrh($optionCount).'
'; } } echo '
'; echo '

'.translate("Nombre total de votes: ").' '.$sum.'


'; if ($setCookies>0) { echo '

'.translate("Un seul vote par sondage.").'

'; } } [/code]

Cet article provient de Labo 16.8 888
https://grottes-et-karsts.org/viewtopic.php?topic=7&forum=1