By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,948 Members | 1,929 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,948 IT Pros & Developers. It's quick & easy.

Make a Quiz with multiple answers.

nomad
Expert 100+
P: 664
I have a general question on how to select multiple question on a quiz.

The quiz is done in html and php, with a post method.
The post info connect to a php file. By the way the the guess are A, B, C, D...

This is part of my code for the multiple question to see if its the aswer is correct or not.

Here I made the A, B, C, D in answers1.1, answers1.2, answers1.3, answers1.4.

Here is part of my code

Your answer was: [PHP]<?php
if ($question2 == "answer2.1")
{
echo ("<b>Correct</b>");
$score = $score + 1;
}
else
{
echo ("<b>Incorrect</b>");
}
?>[/PHP]

Part I need help is here
if ($question2 == "answer2.1")


How do I get to to read multiple answers.
is it like this
[PHP] if ($question2 == "answer2.1"
$$ "answer2.3")
[/PHP]

or this
[PHP] if ($question2 == "answer2.1" $$ $question2 == "answer2.3")
[/PHP]

Both answers have to be selected in order to get the question right.



thanks
nomad
Mar 21 '08 #1
Share this Question
Share on Google+
6 Replies


Markus
Expert 5K+
P: 6,050
Dont understand why youre using the dollar sign.
You have multiple answers? So you want an OR clause (||)

[php]
if(($this == 11) || ($this == 12))
[/php]

Regards
Mar 21 '08 #2

nomad
Expert 100+
P: 664
Dont understand why youre using the dollar sign.
You have multiple answers? So you want an OR clause (||)

[php]
if(($this == 11) || ($this == 12))
[/php]

Regards
Thanks Markusn00b
but will the OR be correct.
sounds like I can have either answer and I will be right. I need both to be chosen to be right.

Just asking????
damon
Mar 21 '08 #3

Markus
Expert 5K+
P: 6,050
Thanks Markusn00b
but will the OR be correct.
sounds like I can have either answer and I will be right. I need both to be chosen to be right.

damon
Oh i see!
Sorry.
Ok, in thatcase use the AND operator (&&)
[php]
if(($this == 11) && ($this == 14))
[/php]

Regards!
Mar 21 '08 #4

nomad
Expert 100+
P: 664
Oh i see!
Sorry.
Ok, in thatcase use the AND operator (&&)
[php]
if(($this == 11) && ($this == 14))
[/php]

Regards!
That's what I thougth
Thanks Markus...
Mar 21 '08 #5

Markus
Expert 5K+
P: 6,050
That's what I thougth
Thanks Markus...
Welcome!

Regards, markus.
Mar 21 '08 #6

nomad
Expert 100+
P: 664
Back to the quiz.
I transfer my files to a Mac and now I'm having problems making php work.
Im using DreamWeaver and XAMPP (XAMPP is working).
When I publish a file in HTML/php in Dreamweaver I get an error
File not found or could not be created.

The quiz is in two parts.
The quiz itself is written in a html/php using forum ie post method.
the other part is written in php this has the results and the correct answers.

The test server is located at xampp\htdocs\
I know that on the PC side you need to modify a couple of files which I can not remember which ones or what to add to it.
I tried going to the forums on XAMPP but there is no info for the mac that is related to this issue. On the PC side there are to many topics to read.

Anyway I hope someone can help me or direct me where I can find this info,

thanks
nomad
Mar 24 '08 #7

Post your reply

Sign in to post your reply or Sign up for a free account.