Mysql columns in a loop
Let's say I have a Mysql table with the columns year_2012, year_2013 and year_2014. I select all columns in the table
$fraga = "SELECT * FROM TABLE WHERE medlemsnr=12 LIMIT 1"; $svar = mysqli_query($conn,$fraga); $row = mysqli_fetch_array($svar); extract ($row); If I want to display the value of year_2013 it works with 'echo $year_2013'. My problem is that I want to make a loop to display all three columns. I have tried this but it doesn't work: for ($theYear=2012;theYear<2015;theYear++) { echo $year_$theYear; } Is there a solution? |
Re: Mysql columns in a loop
Quote:
Your code is PHP, and doesn't seem to be related to SourceMod scripting at all. BTW; in the future, then post your code into [CODE] tags. |
Re: Mysql columns in a loop
This is Scripting Help for SourceMod scripting, but to answer your question:
PHP Code:
|
Re: Mysql columns in a loop
This will work too
PHP Code:
|
All times are GMT -4. The time now is 01:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.