Hello
I am new to PHP as well as arrays.
I am using a select statement to obtain a table from mysql database. I
want to store that table(with two columns Quesid, Numans) in an array
which is sorted according to Numans.
My table looks like this:
Quesid Numans
3 5
2 3
4 2
1 2
5 1
Now I want to store first field of column Numans which is 5 into a
variable, divide it by two and then parse through all the rows of the
array and print that Quesid whcih is closest to 5/2. Once printed
again go through the array with same condition and again print the
next closest one.
I would really appreciate a detailed answer. I am so stuck here.
Thanks,
Sunaina
I am new to PHP as well as arrays.
I am using a select statement to obtain a table from mysql database. I
want to store that table(with two columns Quesid, Numans) in an array
which is sorted according to Numans.
My table looks like this:
Quesid Numans
3 5
2 3
4 2
1 2
5 1
Now I want to store first field of column Numans which is 5 into a
variable, divide it by two and then parse through all the rows of the
array and print that Quesid whcih is closest to 5/2. Once printed
again go through the array with same condition and again print the
next closest one.
I would really appreciate a detailed answer. I am so stuck here.
Thanks,
Sunaina
Comment