Welcome Guest, Not a member yet? Register   Sign In
Table with variable columns
#7

[eluser]bradym[/eluser]
Building from sholnay's example, something like this should work:

Code:
$sql = "SELECT ";

$fields_selected = array('category' => 'selected category', 'style' => 'selected style');

$sql .= implode(',',array_keys($fields_selected));
$sql .= " FROM devices WHERE ";

foreach($fields_selected as $field => $value)
{
   $sql .= $field .' = '. $this->db->escape($value);
}

$this->db->query($sql);

Of course $fields_selected would be the checkbox values the user selected.


Messages In This Thread
Table with variable columns - by El Forum - 05-22-2008, 01:00 PM
Table with variable columns - by El Forum - 05-22-2008, 01:46 PM
Table with variable columns - by El Forum - 05-22-2008, 01:50 PM
Table with variable columns - by El Forum - 05-22-2008, 02:57 PM
Table with variable columns - by El Forum - 05-22-2008, 03:03 PM
Table with variable columns - by El Forum - 05-22-2008, 03:36 PM
Table with variable columns - by El Forum - 05-24-2008, 09:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB