Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic PHP output

Guest
Apr 30, 2007 Apr 30, 2007
I'm writing a page that will allow users to input questions and answers and then display the questions and answers to users so they are able to do the quiz. I'm having trouble with a part of it where I want the quiz writer to be able to input how many questions are asked, I'm having trouble outputting the number of questions specified if that makes any sense. So in my maker page I've got the user specifying the number of questions = 4 and then on the actual quiz I want to output the 4 questions specified. It's kinda confusing, I'm just struggling with the whole dynamic output thing.
TOPICS
Server side applications
286
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 30, 2007 Apr 30, 2007
slowpoke115 wrote:
> I want the quiz writer to be
> able to input how many questions are asked, I'm having trouble outputting the
> number of questions specified if that makes any sense. So in my maker page I've
> got the user specifying the number of questions = 4 and then on the actual quiz
> I want to output the 4 questions specified.

I presume that you want the questions to be selected at random, so this
is the SQL query you need:

SELECT * FROM questions
ORDER BY RAND() LIMIT 4

Since the number of questions will be variable, you need to create a
runtime variable, so you enter this in the Advanced Recordset dialog box:

SELECT * FROM questions
ORDER BY RAND() LIMIT var1

If you're using DW 8.0.2 or CS3, define var1 as Numeric, and set its
runtime value to $_POST['numQuestions'] or $_GET['numQuestions'],
depending on whether you use POST or GET to pass the number of questions
to the page.

There must be no space between RAND and the parentheses.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 02, 2007 May 02, 2007
I dont want random questions, it will make the rest of my code really confusing. At the moment I have a code where the questions and answers are specified, a page where the question created is selected and the output page. All of the details are read/wrote to a database which holds the questions and answers.

I have no idea how to do this really as my php is based on a more complicated version of this: http://www.developingwebs.net/phpclass/phpquizpage.php

If the worse somes to the worse I'll either have a huge case statement for the number of questions specified or make the user write say.. 10 questions leaving none blank.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 02, 2007 May 02, 2007
LATEST
slowpoke115 wrote:
> I dont want random questions,

If you don't want random questions, leave out ORDER BY RAND(). The rest
of the query is the same.

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines