Obviously, you can modify this to your hearts content. But this should give you an idea of how to easily output information from a database into a nice HTML table. From here, you can also modify the above to simply get all the values and put them in values, etc.
On the same theme, I am creating a query using the variable names flag1, flag2 etc. But I have substiuted the numerical part with a variable called $search.
$sql = "select * from flags1 where flag$search = "$s" ";
This works fine - I was just wondering whether it was dangerous to place a variable ($search) along side the begining of the field name? I have tried various alternatives such as flag[$search] but this doesnt work.
As it seems to work OK should I just leave it alone?
I'm not sure why you would want to do this as it's gonna end up querying your table a lot more than is actually needed...
i'm not sure if this is correct or not, but are you suggesting querying the table for specific flags only? like, you just want to show the one you need, and don't have plans looping this query for each individual flag as well? because if you are just wanting to write this for one flag, then sure this is fine.
and just to answer your question, there is nothing wrong with putting variables beside your fieldnames or as your field names. i just recommend exiting the string when you want to call those variables. helps you when you need to do trouble shooting and don't have to search close for those variables when you can just see where you exited the query.