Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Certification - All Discussion
Author Message
testy1
Involved
Involved



Joined: Apr 06, 2008
Posts: 484

PostPosted: Sun Mar 15, 2009 8:23 pm Reply with quote

looks like you have only made slight modifications?

Code:


/** added for random - Random stuff from chatserv **/

mt_srand((double)microtime()*1000000);
$total = $db->sql_numrows($db->sql_query("select * from ".$prefix."_poll_desc"));
if ($total==0) $artrand=0;
else
$artrand = mt_rand(0,($total-1));
$pollID = $artrand;

// OLD list($pollID) = $db->sql_fetchrow($db->sql_query('SELECT pollID FROM '.$prefix.'_poll_desc '.$querylang.' ORDER BY pollID DESC LIMIT 1'));
list($pollID) = $db->sql_fetchrow($db->sql_query('SELECT pollID FROM '.$prefix.'_poll_desc '.$querylang.' ORDER BY pollID DESC LIMIT '.$artrand.', 1'));

/** end add -- translated by draxx **/


Seems to work nice m8
 
View user's profile Send private message
draxx
Involved
Involved



Joined: Nov 19, 2003
Posts: 282

PostPosted: Sun Mar 22, 2009 1:10 am Reply with quote

I actually had chatserv make me a random survey block a long time ago - all I did was take his code snippit out of that block from then and modify it to fit the new format.

I really did nothing but translate a line of code.
 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Tue Apr 28, 2009 8:00 am Reply with quote

My own tests;
Odd and Even numbers of polls (not that it matters) - OK
PollID sanitized using intval() to limit chance of injection in the sql query - OK
Rendered Output - Compliance to XHTML 1.0 Transitional and CSS 3 - Passed
Notice and other PHP errors - None

Comments
To avoid possible clashes with the standard block, I would recommend you change the variable $pollID to something unique.
 
View user's profile Send private message Send e-mail
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Certification - All Discussion

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©