![]() |
[Help]Php and Mysql - Printable Version +- Post4VPS Forum | Free VPS Provider (https://post4vps.com) +-- Forum: Geek World (https://post4vps.com/Forum-Geek-World) +--- Forum: Scripting & Programming (https://post4vps.com/Forum-Scripting-Programming) +--- Thread: [Help]Php and Mysql (/Thread-Help-Php-and-Mysql) |
[Help]Php and Mysql - jayant - 12-24-2016 Hello people, I directly come to the point and ask my question..I was trying to do something using php and mysql.Its just a game type thing in which a random question is picked from database using rand(min,max) and answer given by user is matched with the answer of the database. So, table is quest containing columns qid,question,answer PS: I tried with my stupid approach and trying to explore more ways but none of them are working.I am learning so any guidance will be appreciated.. Thanks, Regards, Jayant. RE: [Help]Php and Mysql - Dynamo - 12-25-2016 So that means some of the questions would have same answers as that of what's user have written ? Can you try to give an example for more clearity ? Thanks, RE: [Help]Php and Mysql - jayant - 12-26-2016 No, the question and answers are not repeated..Each question has an id,question and answer..I was just making a thing by which I don't have to send user an OTP or activation email,my aim is to ask a random question to a newly registered user then,If he answer the question correctly (i.e his answer matches with the answer of asked question from database),then I will update a column and mark the user as active.Hope it clears what I want to achieve,but If not,then I post a code here so that It will make you clear about my question. Assume,something like this: qid question answer 1 2 + 2 4 2 4 / 2 2 3 2 x 2 4 My select query: PHP Code: $random_id = rand(1,3); Suppose, question is 2 + 2,so user must answer 4(so it gets matched with the answer of the table). Waiting for reply. RE: [Help]Php and Mysql - Dynamo - 12-26-2016 ohk tried something. for example here are a bunch of questions with there answers defined at question_list table by the admin/you at the db. ![]() here is he code: PHP Code: $sql = "SELECT * FROM question_list order by RAND() LIMIT 1"; and here is the live review what the code does: ![]() And if you want do implement a checking type system then you can try this: index.php: PHP Code: include 'config.php'; and the check.php file can be like this: PHP Code: include 'config.php'; ![]() if you want config.php also then here it is: PHP Code: $connect_db = mysqli_connect("hostname here", "username of account of mysql", "accountt password", "databasename"); RE: [Help]Php and Mysql - jayant - 12-26-2016 Thank you so much for help..Loved your explaination,it was just a few things but I made things critical,but your code made things so easier for me and helped me alot.I think I to have develop my logics and should practise more..Will post more here if I will need help. ![]() RE: [Help]Php and Mysql - Dynamo - 12-26-2016 Closing this topic since the Problem has been resolved. Use report button if you wants to reopen the thread. |