chat quiz.

Started on the old forum in August 2009 · view the original in the archive · old links redirect here

7 replies · 558 views · started 17 years ago · 1 min read

3 participants
nclemale36 Lead · 537 posts #1

ok guys got this code from the chat.php in wap.net.ph

its part of the quiz code . my problem is it seems to be only selecting the one question which is id 14 out 30 . which would suggest to me its the middle one all the time as the code suggests its gets the max and min question.

$range_result = mysql_query( " SELECT MAX(`id`) AS max_id , MIN(`id`) AS min_id FROM `ibwf_quiz` ");
$range_row = mysql_fetch_object( $range_result ); 
$random = mt_rand( $range_row->min_id , $range_row->max_id );
$result = mysql_query( " SELECT question, answer, id FROM `ibwf_quiz` WHERE `id` >= $random LIMIT 0,1 ");
while($rpgds=mysql_fetch_array($result))

can anyone help me so it selects the questions at either totally random or in order.

thanks .

nclemale36 Lead · 537 posts #2

can anyone help here with this . it inserting new questions now but even when a user answers the correct answer it says nobody answerd correctly.

heres the full file .

Attachments: chat.rar
kiLLeR-eyEd_14 Senior · 382 posts #3

nclemale36 wrote: can anyone help here with this . it inserting new questions now but even when a user answers the correct answer it says nobody answerd correctly.

heres the full file .

copy table ibwf_quiz and create table ibwf_quizrooms..just remove i think answers 2, 3..and 4?

nclemale36 Lead · 537 posts #4

i have all tables required to make this work . like i say it dont pick up the answer inserted . ?? there is a quiz table and a quizroom table needed .

kiLLeR-eyEd_14 Senior · 382 posts #6

nclemale36 wrote: i have all tables required to make this work . like i say it dont pick up the answer inserted . ?? there is a quiz table and a quizroom table needed .

just use ur head here, i'll give u the codes..no more questions..put this inside if(!isblocked($message,$uid)).. change the rid of your quiz room..

if($rid==15)
{
$msg = $message;
$ans = "/$question2/i";
if(!preg_match($ans, $msg))
{
 $by = getnick_uid($uid);
echo "<b>Chat system</b>» $by, sorry your answer is wrong. You've been deducted 2 plusses. Please try again!!!<br/>";
mysql_query("UPDATE ibwf_users SET plusses=plusses-'2' WHERE id='".$uid."'");
}else{
$range_result = mysql_query("SELECT MAX(`id`) AS max_id, MIN(`id`) AS min_id FROM `ibwf_quiz`");
$range_row = mysql_fetch_object($range_result);
$random = mt_rand($range_row->min_id , $range_row->max_id);
$result = mysql_query("SELECT question, answer, id FROM `ibwf_quiz` WHERE `id` >= $random LIMIT 0,1");
while($rpgds=mysql_fetch_array($result))
{
$winner = $rpgds[0];
$winner2 = $rpgds[1];
}
 mysql_query("DELETE FROM ibwf_quiz WHERE id='".$question3."'");
mysql_query("INSERT INTO ibwf_quizrooms SET displaytime='".time()."', question='".$winner."', answer='".$winner2."'");
$by = getnick_uid($uid);
$csmsg = "$by, you are correct. you got $kano plusses. Next question!!!";
$csm = "$by, i'm sorry but it's already time out!!!";
if($kano!="")
{
echo "<b>Chat system</b>» ".$csmsg."<br/>";
mysql_query("UPDATE ibwf_users SET plusses=plusses+'$kano' WHERE id='".$uid."'");
}else{
echo "<b>Chat system</b>» ".$csm."<br/>";
mysql_query("UPDATE ibwf_users SET plusses=plusses+'$kano' WHERE id='".$uid."'");
}
mysql_query("DELETE FROM ibwf_quizrooms WHERE id='".$question3."'");
}
}
Vayne Developer · 106 posts #8

if question selects from sql base, than in selection query put

ORDER BY RAND

Nous Ne Dansos Pas, Nous Sommes Le Danse.!

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close