Home | Forum | Documentation

Code Stylist Documentation





Home | Docs | Entry 27



One way of filtering results in a record set

I was populating a drop down list in a template with content from a table called "usapages," but wanted to have a more specific query that would limit the data grabbed from this table by the controller function.

I was using the following line in my _new function in the controller:

$page_id_options = $db->distinct_values( "usapages", "link" );

but I wanted to limit the values from the "usapages" table by using a custom MySQL query. So I replaced the above line with this:

$page_id_options_x = mysql_query("SELECT page_id,menu_title from usapages WHERE level='1' and visibility='public'");
   while ($result=mysql_fetch_array($page_id_options_x, MYSQL_NUM)) {
       $page_id_options[$result[0]] = $result[1]; }









Sign In to post comments







Bookmark this page:








Sign In



Click here to become a member. It's free and convenient.