Note that there are some explanatory texts on larger screens.

plurals
  1. POMySql PHP row request to variable
    text
    copied!<p>Hello I need some help on a project i am working on. </p> <p>I have a database with a large amount of records in it. I need to get a number of records into variables to make a graph. Below is part of my code so far.</p> <pre><code> //Retrieve all data from the table $result=mysql_query("SELECT * FROM solar_panel ORDER BY 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); </code></pre> <p>As you can see this will get quiet large, i need to get every 5th row in descending order put into a separate variable but the only way i know is to put all the rows into separate variables then use the 5th one in the graph data.</p> <p>I would like to do this for about 60 records so to write out all the records i would have to write the above code 300 times. Is there a quicker way to do this.</p> <p>i have tried doing a loop but can't get the variables to increase with each row selected.</p> <p>Any help would be much appreciated, or im writing a lot of code</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload