eddix
Changing random results to ASC or DSC
0 Answer(s)      5 years and 4 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
display database results
display database results  how to display database results using php
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
using random number
using random number  generate a 10 digit number using random number and display the length of longest increasing series
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
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
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
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 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
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