473,804 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there a JavaScript that will randomly select files from a database?

1 New Member
This is what I am looking for. So I will basically have two databases. One with the questions and one with the answers. Each database will have several tables. For example questions in database 1 table 2 will have corresponding answers in database 2 table 2. I would like a script that will randomly select a question from a table in database 1 and depending on which table it randomly selected the question from, it will then automatically go to the corresponding table in database 2 and randomly select 3 questions from that database. I basically just need the script to perform these actions. The design of the actual game is not as important at this point. Is this something you can help me out with?
Mar 2 '11 #1
2 2271
Rabbit
12,516 Recognized Expert Moderator MVP
I'm baffled as to why your questions and answers are split across multiple table and why your answers are in a different database.

But aside from that, you just need to use the random number generator function: Math.random()
Mar 2 '11 #2
James Kalmadge
3 New Member
If I understand the situation:
I believe that you will also need some kind of identifier column in the DBs for the program to know which question was asked and be able to match it to the correct answer.
Mar 8 '11 #3

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

Similar topics

3
2019
by: Bob Bedford | last post by:
I've a site where companies add their article. I'de like to provide a "lasts articles" table. By this, I'll show last articles inserted. But I won't always the same articles at any refresh. Question 1: how to get a "random" selection from the database, giving more priority to the last inserted (the ones with higher articleID) Question 2: I'd like to provide one article by client. I won't show 3 articles from the same client only because...
1
1716
by: Jonathan Rubke | last post by:
I am getting a filename from one frame and opening it in another frame. It works fine if the file exists, but I'm trying to get it to show an error message, possibly an alert box, if the file doesn't exist. Right now, if it doesn't exist it just gives a error "page not found" in the frame I'm trying to open it in. Here is my code. function PullPage() { for (var i=0; i<document.Page.Letter.length; i++) { if...
0
1825
by: Mikko Pulkkinen | last post by:
Hi, I'm trying to use Crystal Reports to generate reports from an Access database. I'm using VS2003 and C#. I need to select the database the report uses as data source at runtime. The database does not have any password protection. I've tried using ODBC connections, but all I get is logon errors. It seems that I should be able to pass a connection string in
3
2279
by: Jess | last post by:
I have tried all of the solutions given by other members on how to load a random .swf file on the load of the page, however, none of them seem to work on my site. The problem is in embedding the random .swf in the object tag of my code. Could someone please shed some light on this issue for me because I'm clueless on this one?
1
1558
by: Jan | last post by:
Hi there, I have the following problem: Is there a way to select files on time or date. I mean on the time that they are saved. I have a lot of files with a certain save time/date. Thx
2
2563
by: Scott Gordo | last post by:
<!--Newbie warning--> I've got a csv file with names, addresses, emails, etc. I've been asked to randomly select a name from a csv file. I've found plenty of RandNum examples, but I'm not sure how to apply it to these names. Can anyone point out a sample I could use? TIA! Scott
4
1663
by: tjbvo | last post by:
Greetings I am busy with a program that randomly selects data from a databse and then populates controls with the random data. the user must then select an option that must be stored for printing at the end of the program. Below I have pasted my code. I am using VB6 and MSAccess Database. Thanking You in Advance. Julian
5
5809
by: Edwin Smith | last post by:
Hello: I'm using VS2005 with an ODBC database. I am trying to add a Dialog to an existing Database application to allow the user to select the database. We have 2 different databases with the same schema so this is a very desirable function. I can configure 2 different connection strings in app,config but I can't figure out how to allow the user to select one or the other.
1
1472
by: fran7 | last post by:
Hi, I have this code to randomly select an image from a sequence of fields in my database. Does anyone know if rather than random, one could simply move from one field to the next sequentialy. That would stop the problem of it randomly selecting the same field twice? The idea is that on page refresh the next pic is selected. It works a treat randomly. I have been told its not possible as how does the webpage remember what the last pic...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10090
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.