473,322 Members | 1,614 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,322 software developers and data experts.

how to display only 3 different questions everyday from database?

127 100+
i want to display questions and multiple answers from database. this code will display all the questions from the database. i want to display only 3 questions daily. every day new set of question should be displayed... how to do it?

Test.php

Expand|Select|Wrap|Line Numbers
  1.  
  2.     <?php 
  3.         include("config.php");
  4.         session_start();
  5.         include("lock.php");
  6.     ?>
  7.  
  8.     <?php
  9.         echo "<form method='post' id='submit' action='checkresult.php'>";
  10.  
  11.         $sql="SELECT * FROM cquestions";
  12.         $result=mysql_query($sql);
  13.  
  14.         while ($row = mysql_fetch_array($result)) {
  15.             echo "<p>" . $row['cqtext'] . "</p>";
  16.             $sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
  17.             $result2=mysql_query($sql2);
  18.             while($row2=mysql_fetch_assoc($result2)){
  19.                 echo "<input type='radio' name='".$row['cqid'].
  20.                         "' value='".$row2['ccans']."' />".$row2['aatext'];
  21.             }
  22.             /*echo "<input type='hidden' name='email' value='email' />";*/
  23.         }
  24.         echo"<input type='submit' id='submit' name='submit' value='Submit Answers'/>";
  25.         echo "</form>";
  26.     ?>

May 19 '13 #1
6 1547
Luuk
1,047 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. SELECT rand(), c.* 
  2. from cquestions as c 
  3. order by 1 
  4. limit 3,
  5.  
This will display only 3 rows ('limit 3') with the smallest random number ('rand()')
May 19 '13 #2
Rabbit
12,516 Expert Mod 8TB
You will need to keep track of those that you already displayed by using a flag or counter of some sort and either filter those flagged out or sort by the counter.
May 19 '13 #3
impin
127 100+
okay. but it will display random questions every time the page loads.i want do display 3 questions one full day. only the next day the questions should change.
May 22 '13 #4
Rabbit
12,516 Expert Mod 8TB
Yes, take Luuk's SQL and implement my modification and you will get what you want.
May 22 '13 #5
Luuk
1,047 Expert 1GB
You will also have to give a definition to 'one full day'.
The internet is something world-wide.

Where i am living it's now 22:09, so in 2 hours another day will start... But, will this also be a fact for all your visitors?

(My local timezone is CEST, or +02:00)
May 22 '13 #6
neo008
85
Yes, Luuk is right. Either you assume your web-server's time to consider a day or correct it for your local time zone.

Now that depends on your requirement, if the web-server's date/time is more suitable to you and if you have saved the date into your database/same table than simply put where condition (where date between dd/mm/yyyy and dd2/mm2/yyyy2 )with above solution.

NE☼
May 25 '13 #7

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

Similar topics

3
by: harish | last post by:
Hi friends I am facing problem as follow I can't display image from SQL Database to Picture box Control. Here are the codes that I am writing Dim arrPicture() As Byte = _
0
by: arunpillai | last post by:
hi guys, My problem is i need to display different html page in content place holder just like how we will be doing in the frames. I have a menu control when ever the menu is clicked the particular...
0
by: teknowledgy | last post by:
Hi All, This is my first post to this group and I have a very specific question. My SQL database has has four tables. A couple of the columns in these tables use the xml data type which...
7
by: eholz1 | last post by:
Hello Group, Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed...
2
by: =?Utf-8?B?Z2FuZQ==?= | last post by:
Hi, In a gridview, How can i display different columns between item and edit modes. For eg. i have a sql that returns productname, categoryname, etc. In viewmode, i need to display only...
1
by: demo123 | last post by:
Hello, Please if any one can help me ... I want to display different value in Y-axis which i am using for calculation.. like i am using monthly salary for the calculation but i want to...
1
by: tarabztk | last post by:
MSACCESS 2003 : How to use command buttons to display different subforms I have an application that display information about Pipelines and these pipelines have many other equipments attached to...
0
selvasoft
by: selvasoft | last post by:
Hi Please help me any one. I want solution for display multiple images from oracle database.Using JSP. here is my code for display one image from database. Please Any one give me some ideas. ...
1
by: ashfaqbinnazar | last post by:
Dear friends, How can i display messages from mysql database in each rows with delete and reply button. Thanks in advance. Here is my code. i have created a page like scrapbook. and splitted the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.