Games like 'Trivia'

Back to PHP-IRC Feature Requests

Page: 1  
From User Message Body
Post #704
Date: 9:05 pm, Mar 15 2008
Posts: 4

I think it will be funny if games like 'trivia' will be included into php bot :D

#Scripting @
Post #705
Date: 9:08 pm, Mar 15 2008
Posts: 9

You can write a trivia-module that retrieves data from and stores data in a MySQL DB. Shouldn't be that difficult to do. =)

Post #706
Date: 9:19 pm, Mar 15 2008
Posts: 4

I want but I haven't knowledge. I'm newbie. I'll buy a book about php soon, I hope :)

#Scripting @
Post #714
Date: 10:46 pm, Apr 10 2008
Posts: 15

It would be preferrable if it were able to take questions from a file; most of the trivia questions out there are in file format, not in sql databases.

Post #965
Date: 2:22 am, Apr 9 2009
Posts: 22

Im doing a sql-driven trivia modul now but if anyone by any chance might be intrested i used this bit of code to parse a txt file to the database.


$data = "";
$id = 0;
$fileData ="";    
$fileData = file('questions.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($fileData as $line_num => $line) {
        $data = explode("*", $fileData[$id]);
        $temp = time();
echo '<br>ID:'.$id.' Q:'.$data[0].' Awn:'.$data[1];
    $data[0] = preg_replace("/'/", "\'", $data[0]);
    $data[1] = preg_replace("/'/", "\'", $data[1]);
    $sql = "INSERT INTO trivia 
        (`added`, `addedby`, `category`, `question`, `type`, `choises`, `awnser`)
        ('".$temp."', 'core', 'Övrigt', '".$data[0]."', '0', 'FALSE', '".$data[1]."')";
    $reulst = dbquery($sql);

This worked mostly from a file with one question each row and the syntax..

warning thou
this code is not well thought out. but it got 5000 Q's into my db. Now i just gotta run some other scripts on it for better format. But its a start.

Oh and check the date on this post. How leet is that. Posting before the post above. (:


Back to PHP-IRC Feature Requests