Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa SQL Changing random results to ASC or DSC

Have Programming Question? Ask it here!
 
 
 


eddix
Changing random results to ASC or DSC
0 Answer(s)      4 years and 3 months ago
Posted in : SQL


I have a script that randomizes results. I have tried to convert code to display a constant result, ascending or descending while in session. I can't seem to convert script due to session value and $rand_num = rand(1,$total_rows - 1);

//index.[php]


$query = "SELECT * FROM ".$quiz;
$sql = mysql_query($query);
$total_rows = mysql_num_rows($sql);
$i=0;
array($rand_arr);
while($i < $_SESSION['quiz_total_question'])
{
$rand_num = rand(1,$total_rows - 1);
if(!@array_search($rand_num,$rand_arr))
{

$rand_arr[$i] = $rand_num;
$i++;
}
}
global $quiz_data;
for($i=0;$i < $_SESSION['quiz_total_question'];$i++)
{
$query = "SELECT * FROM ".$quiz." WHERE id = ".$rand_arr[$i];
$sql = mysql_query($query);
$quiz_data[$i] = mysql_fetch_array($sql);

}
$_SESSION['quiz_data']=$quiz_data;
//print_r($quiz_data);
}
elseif(isset($_POST['next_step']))
{
$error = "Some of the fields are left empty !";
header('Location: index.[php]?menu=setup');
}

Advertisement
View Answers

Related Tutorials/Questions & Answers:
Changing random results to ASC or DSC - SQL
Changing random results to ASC or DSC  I have a script that randomizes results. I have tried to convert code to display a constant result, ascending or descending while in session. I can't seem to convert script due to session
Mysql ASC Order
Mysql ASC Order       Mysql ASC Order is used to sort the result set by ascending or descending order... with Example The Section of this Tutorial illustrate an example from 'Mysql Asc Order
Advertisements
Results
Results After action executes business logic, <result > tag is used to display the View. Struts2 provides or supports to 11 types of Results... other ways to render results: Result type is linked to View. Besides the "type
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
Random classes
Random classes  Hello... What is Random class? What's the purpose
changing of data...
servlet.database is not changing in 10 second  hi.... i have created a servlet page using a response.setheader(); method.in the parameter i have... this servlet.database is not changing in 10 second...what should i do..?? reply fast
changing of data...
data changing in 10 second  hi.... i have created a servlet page using a response.setheader(); method.in the parameter i have given 10 second.but... is not changing in 10 second...what should i do..?? reply fast
changing of data...
changing of data...  hi.... i have created a servlet page using a response.setheader(); method.in the parameter i have given 10 second.but once... is not changing in 10 second...what should i do..?? reply fast
random number
random number  Sir could u please send me the code registration form of roseindia.net with image varification
random number
random number   Please How do I generate a program that gives me random integer from 115 to 250? Using java.util.random. Thank you very much!  ...[] args){ int min = 115; int max = 250; Random random = new Random
random numbers
random numbers  hi.. i am creating a website and on feedback form to authenticate user i want to generate a random number on label.if user types that number correctly in textbox then he is allowed to submit feedback otherwise
Pick at Random
the entry from the array before selecting another name at random
random numbers
random numbers  Hi I need some help with the code for the this program. This program should randomly choose a number between 1 and 1000, and then challenge the user to guess what it is, giving hints ('too high!' or 'too low
Random Access File.
Random Access File.  Explain Random Access File
changing uiview background color
changing uiview background color  changing UIView background color in ios   self.view.backgroundColor = [UIColor colorWithRed:244.0f/255.0f green:230.0f/255.0f blue:183.0f/255.0f alpha:1.0f
Changing root Password
Changing root Password  how do i change the root password in mysql
how to show random image in ASP.net?
how to show random image in ASP.net?  hello bros i saw in many websites..there is a programming of random image changing.... i want to use this in my ASP.NET websites, can any one suggest me code or any kind of help..so that i
jtable displays search results
jtable displays search results   hi sir can u send me full source code for displaying search results into jtable from database n jtable n search button must be within same frame but in different Panel and the size of the frame
using random number
using random number  generate a 10 digit number using random number and display the length of longest increasing series
Show results in HTML
Show results in HTML  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field table. Actually
Random Access File class
Random Access File class  Write a short note on Random Access File class.   Please visit the following link: Java Random Access File
Changing pictures - Java Beginners
Changing pictures  I found some html code that allows pictures to be changed on a web page. I copied the code and saved it as an html file. when I... Explorer that have pictures changing on them and they do not get blocked? 
Changing MySQL Port Number
Changing MySQL Port Number  How to change the MySQL port no in windows.   Hi, Open the my.ini file present in the MySQL server installation directory. Change the port number to desired port number. By default port
getting random number in java
getting random number in java  getting random number in java Hi everyone, i am trying to get a random number in a particular range. for example random numbers between 1 to 100 in Java. Though i m new to Java, i have tried many
Changing 2D graph using slider.
Changing 2D graph using slider.  Code for changing a 2d graph with help of slider
Generate Random Numbers
Generate Random Numbers  hi,,, Please give me answer with example How do you generate random numbers within a given limit with actionscript... This function generate random numbers with in given limit
Random data - Java Beginners
Random data  hi friend, I want to ask how to make random data. i has example word like this : Gaza! Gaza! Palestina merdeka! how to make random like : Azag! Azag! Anitselap akedrem! thank's
changing selection color of <button>
changing selection color of   dear all, i have loaded image in border less button tag when button is selected with tab key i get brown color rectangle around image. how do i change color of that rectangle from brown to white
changing the file content
changing the file content  I have requirement like this, a file contain maximum 1000 lines. I want to cahnage the 501 line content. I know this logic , reading the file content and changeing the 501 line content and crating one
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  In a random access file, first write the alphabets a,b, c, d till z. Read the file in reverse order and print it on screen
using random number
using random number  generate 10 number and display the length of longest incresing series
using random number
using random number  generate 10 digit number and display the length of longest incresing swries
random numbers - Java Beginners
random numbers  write a program to accept 50 numbers and display 5... java.util.*; class RandomNumberExample { static Random generator = new Random...(); System.out.println("Random numbers are: "); int random[]=new int[5]; for(int i=0;i
Random numbers - Introduction
Java NotesRandom numbers - Introduction When to use random numbers There are many types of programs that use random numbers. Game programs use them... situation, or a deck of cards must be shuffled. Simulations usually use random
MySQL ASC
in ascending order. But you can explicitly mention the order of the result by ASC keyword. ASC determines that the results will be shown in ascending order. If you want... MySQL ASC      
Random in jsp
Random in jsp          Random numbers are the numbers that are determined entirely by chance. User does not have any control over the working of random numbers
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program that stores the names of four employees in an array of strings. Store the contents of the array in an alphabetical order in a file and display it back on console. Do not use
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some details in it.When clicking on the submit button it gives me a password... to generate a random password and insert into database... Please help me out
Random numbers - Development process
Random numbers  hi, How to generate unique random numbers between range like(10 to 50)  Hi friend, class RandomNumber { public static void main(String[] args) { //set the variable aNumber
random numbers - Java Beginners
random numbers  Hello i need this code to be modified for me to display the random numbers, but not twice or more. I mean i need a number... RandomNumberExample { static Random generator = new Random(); public static int get (int[] array
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to use a File object and print even numbers from two to ten. Then using RandomAccessFile write numbers from 1 to 5. Then using seek () print only the last 3 digits
Generating random numbers in a range with Java
Generating random numbers in a range with Java  Generating random numbers in a range with Java
random color fill
random color fill   Hi I am trying to create a randomly color filled oval but the outcome is a black filled oval this is the code: package...; Random rcolor = new Random(); int r = rcolor.nextInt(255); int g1
Hibernate Criteria :Ordering the results
In this section, you will learn about ordering the results using Hibernate Criteria query
STRUTS-display search results - Struts
STRUTS-display search results  Hii, I am a beginner in struts..I want to retrieve few records from database and display in jsp page.First i tried... them in jsp.. Search Results
RANDOM ACCESS FILE CONCEPT
RANDOM ACCESS FILE CONCEPT  Write a program to write the details of an employee to a file. Details such as year of joining, department code, employee name and salary should be included. You must use RandomAccessFile
 

 

 

DMCA.com