MySql PHP row request to variable -


hello need on project working on.

i have database large amount of records in it. need number of records variables make graph. below part of code far.

 //retrieve data table  $result=mysql_query("select * solar_panel order id desc") or     die(mysql_error());  $row = mysql_fetch_row($result); $row1 = mysql_fetch_row($result); $row2 = mysql_fetch_row($result); $row3 = mysql_fetch_row($result); $row4 = mysql_fetch_row($result); $row5 = mysql_fetch_row($result); $row6 = mysql_fetch_row($result); $row7 = mysql_fetch_row($result); $row8 = mysql_fetch_row($result); $row9 = mysql_fetch_row($result); $row10 = mysql_fetch_row($result); $row11 = mysql_fetch_row($result); $row12 = mysql_fetch_row($result); $row13 = mysql_fetch_row($result); $row14 = mysql_fetch_row($result); $row15 = mysql_fetch_row($result); $row16 = mysql_fetch_row($result); $row17 = mysql_fetch_row($result); $row18 = mysql_fetch_row($result); $row19 = mysql_fetch_row($result); $row20 = mysql_fetch_row($result); $row21 = mysql_fetch_row($result); $row22 = mysql_fetch_row($result); $row23 = mysql_fetch_row($result); $row24 = mysql_fetch_row($result); 

as can see quiet large, need every 5th row in descending order put separate variable way know put rows separate variables use 5th 1 in graph data.

i 60 records write out records have write above code 300 times. there quicker way this.

i have tried doing loop can't variables increase each row selected.

any appreciated, or im writing lot of code

query 5th row

if you're interested in 5th row, request row db:

select * solar_panel order id desc limit 4, 1 

index limit zero-based, 5th row has index 4.

query every 5th row

if want every 5th row use more complex query:

select *    (select *,            @row := @row + 1 rownumber solar_panel,            (select @row := 0) var            order id desc    ) ordered rownumber % 5 = 0 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -