473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to display one question in each page in php?

127 100+
i have a code that display 3 questions and multiple answers from database for user to select. after choosing the answers user will hit the submit button. its works fine.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $today=date("Y-m-d");
  4. echo "<form method='post' id='submit' action='checkresult.php' dir='rtl'>";
  5. $sql="SELECT * FROM cquestions where showdate='$today' limit 3";
  6. $result=mysql_query($sql);
  7. while ($row = mysql_fetch_array($result)) {
  8. echo "<p>" . $row['cqtext'] . "</p>";
  9. $sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
  10. $result2=mysql_query($sql2);
  11. while($row2=mysql_fetch_assoc($result2))
  12. {
  13. echo "<input type='radio' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext']; }
  14. }
  15. $tomorrow= date("Y-m-d", strtotime("tomorrow"));
  16. $sql4="SELECT * FROM qupdate";
  17. $result4=mysql_query($sql4);
  18. $last_update=mysql_result($result4,"last_update");
  19. if($last_update==$today)
  20. {
  21.     $cqid=mysql_result($result,"cqid");
  22. $update1="update cquestions set showdate='$tomorrow' where showdate='0000-00-00' and cqid!='$cqid' order by cqid limit 3";
  23. mysql_query($update1);
  24. $update2="update qupdate set last_update='$tomorrow'";
  25. mysql_query($update2);
  26. $sql3="SELECT * FROM qupdate";
  27. $result3=mysql_query($sql3);
  28. $last_update=mysql_result($result3,"last_update");    
  29. }
  30. echo"<br>";
  31. echo"<br>";
  32. echo"<input type='submit' id='submit' name='submit' value='Submit Answers' />";
  33. echo "</form>" ;
  34. ?>
output of the above code:



i want make some changes.
i want to make it to display 1st question in first page, and user clicks next then it must go to 2nd question, then 3rd question and finally submit button.

expecting output
page1
question 1
ans1, ans2, ans3, ans4

next

after choosing the ans user clicks next
page2
question 2
ans1, ans2, ans3, ans4

next

page3
question 3
ans1, ans2, ans3, ans4

SUBMIT

how to make it?
Jun 16 '13 #1
3 1698
Rabbit
12,516 Expert Mod 8TB
Have it resubmit to the same page. Just add in a new parameter to pass between the page: the question number.
Jun 16 '13 #2
You can do this by submitting the question on the same page with query string as Question_ID.
Jun 18 '13 #3
Claus Mygind
571 512MB
Two ways I can think of
1) create 3 <form> </form> on the main page. Add a submit button to each form. Each form would have a separate action.

2) Just use a <input type="button" value="" onclick="" /> for each question. then in the onclick event handler just add a form.submit() with specific paramters.
Jun 21 '13 #4

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

Similar topics

5
by: Rajani | last post by:
Hello, I have a strange problem. I want to check the privilege of the login user on each page and allow to display if has suff. priv. I am storing the privilege is session variable. I am...
0
by: Glen | last post by:
Is there any way to post data to an ASP.Net form and then display the page to the user with the posted data from a client app? Here's what I'm trying to do: Serialize a business object (order)...
11
by: Laurent Compere | last post by:
Hi, I'm trying to do something I thought easy. Explanation : I've recently bought a Multimedia Player DVX-500E. This player is connected via ethernet on my local network et allows among other...
1
by: David Thielen | last post by:
Hi; I would like to display a page then immediately cause a post back (the 1st page will have a big "working..." on it, then in the post back do my query which will take a couple of seconds, and...
14
by: lmttag | last post by:
Hello. We're developing an ASP.NET 2.0 (C#) application and we're trying to AJAX-enable it. We're having problem with a page not showing the page while a long-running process is executing. So,...
1
by: jmacduff | last post by:
I would like to be able to display page load times within our asp.net application for debugging purposes , I am seeing some random slowness in our application and a load time metric would really...
3
by: phil67b | last post by:
Hello everybody, I have a page rech.php where I'm doing a multi-criteria research Ex. choose your car model, choose your country. After validation of my form, on the same page, the lines will be...
0
tjc0ol
by: tjc0ol | last post by:
Hi guys, I'm a newbie of this stuffs, We had a small office network (1 Windows 2K - Server) and (3 Windows XP - Client). I am testing to 1 PC (Windows 2K) installed with Licensed Wingate...
7
by: Arunansu | last post by:
How shall I count (Sum)a running total of each page and display and finally show the grand total and display the same in the last page in MS-Access Report? Please help me. Arunansu Dasgupta
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.