I have these three statements that I repeat in my code for each id or variable.
$firstname_sql = $db->sql_query('SELECT column FROM table WHERE id = 1');
$lastname_sql = $db->sql_query('SELECT column FROM table WHERE id = 2');
etc..
$firstname_row = $db->sql_fetchrow($firstname_sql);
$lastname_row = $db->sql_fetchrow($lastname_sql);
etc..
$template->assign_var('FIRSTNAME', $firstname_row['variables'];
$template->assign_var('LASTNAME', $lastname_row['variables'];
etc..
- What would be a more efficient way of writing these?
I've tried selecting the column count and use that in a for loop for the id's but it ends up being as much if not more code as I have now.
- Also, I use sql_query to query the database for the column and it returns an object. Then I have to do sql_fetchrow to get the actual value. Is there a way to do this in one go/line?
I use one table for this and it looks like this:
module_id, int, primarykey
form_id, int, primarykey
form_name, varchar
active, int
The column I'm selecting is active and the id is the form_id. I'm using it to see which forms are active and which are not.