I am using php to get some data from mysql table. The table returns the right results however because the table has many columns, i thought that i could create a for loop for this and save all my values as val1, val2 etc. I am first using a while loop as there can be several rows:
while($row1 = mysql_fetch_array($sql2)){
for($i = 1; $i < sizeof($row1); $i++) {
$val.$i = $row1[$i];
}
However for some reason sizeof($row1) returns 40 whereas i have only 18 columns in that table.
I think $val.$i = $row1[$i]; is not the right way to declare a variable?
I know i would have made a silly mistake, but i am unable to figure it out. :S
You’ll want to specify the result type:
From the manual: