get_all_form($select_fields = null, $sort_by = null)

See also _lookup_ie_all()

Queries the database for all records to create an array of elements to pass into a get_field_ie() or _lookup_ie() function (select or radio).

get_all_form() will only work if the table has 1 primary key

Select fields are the fields that will be displayed (the form value will be the primary key of the table).

Example:

example.php

<?php
include("lib.php");
load("person");

$p = new person($_GET['person_id']);
if (
$person $_POST['person'])
{
        if (
$errors $p->set_from_array($person))
        {
                echo 
"Errors: ".impload(", "$errors);
        }
        else
        {
                if (!
$p->update())
                {
                        echo 
"Failed to update person";
                        return 
0;
                }
                echo 
"Person successfully updated";
                return 
0;
        }
}
else
{
        
$_POST['person'] = $p->set_to_array();
}

/*
these will both do the same thing, the top one offers slightly more customization if you'd like to choose several fields or how to sort
$business = new business;
$list = $business->get_all_form('name, industry', 'name asc, industry desc');

// OR

$list = $p->get_person_has_business_lookup_ie_all('name');
*/

$business = new business;
$list $business->get_all_form('name, industry''name asc, industry desc');

$multiple true;
?>

<form method=post action=example1.php?person_id=<?=$_GET['person_id']?>>
<table>
 <tr><td>Name:     </td><td> <?=$p->get_name_ie('textbox'$_POST['person']['name'], 20)?>           </td></tr>
 <tr><td>Address:  </td><td> <?=$p->get_address_ie('textbox'$_POST['person']['address'], 20)?>     </td></tr>
 <tr><td>City:     </td><td> <?=$p->get_city_ie('textbox'$_POST['person']['city'], 20)?>           </td></tr>
 <tr><td>State:    </td><td> <?=$p->get_state_ie('select'$_POST['person']['state'], 'states')?>  </td></tr>
 <tr><td>Zip:      </td><td> <?=$p->get_zip_ie('textbox'$_POST['person']['zip'], 20)?>             </td></tr>
 <tr><td>Phone:    </td><td> <?=$p->get_phone_ie('textbox'$_POST['person']['phone'], 20)?>         </td></tr>
 <tr><td>Email:    </td><td> <?=$p->get_email_ie('textbox'$_POST['person']['email'], 20)?>         </td></tr>
 <tr><td>Age:      </td><td> <?=$p->get_age_ie('textbox'$_POST['person']['age'], 20)?>             </td></tr>
 <tr><td>Birthdate:</td><td> <?=$p->get_birthdate_ie('textbox'$_POST['person']['birthdate'], 20)?> </td></tr>
 <tr><td>Salary:   </td><td> <?=$p->get_salary_ie('textbox'$_POST['person']['salary'], 20)?>       </td></tr>
 <tr><td>Business: </td><td> <?=$p->get_person_has_business_lookup_ie('select'$_POST['person']['person_has_business_lookup'], $list$multiple)?> </td></tr>
 <tr><td><input type=submit value=Submit>
</table>
</form>