Hi,
I need a little help with the DB API. I made a module that displays a new table that I created that is fed with a form. The display was pretty easy using getHTMLGrid. What I would like to now now is output for each row a delete button....that where I’m stuck. Any ideas on how to do that or any thoughts?
Thank you very much.
Chris
-
☆ A M B ☆
- 756 Posts
Use the same DBAPI class to get all the records you want, then you’ll have to create some PHP code for form handling and html to display the delete action.
take a look at the makeArray
http://wiki.modxcms.com/index.php/API:DBAPI:makeArray function and in the example the second foreach loop would be replaced with your desired html rendering with the added form controls for each delete button.
Example:
global $modx;
$output = '';
$table = $modx->getFullTableName( 'members' );
$result = $modx->db->select( 'id, name, picture', $table, '', 'name ASC', '' );
$members = $modx->db->makeArray( $result );
foreach( $members as $p_val ) {
$output .= '<form methhod="post" action=""><input type="hidden" value="'.$p_val['id'].'" name="id"><input type="submit" name="submit" value="Delete">ID: '.$p_val['id'].' Name: '.$p_val['name'].' Pic:'.$p_val.'</form>';
}
of course you still need your form handler code
cheers
Evo Revo // Ubuntu, CentOS, Win // Apache 2x, Lighttp (Lighty)
Visit
CharlesMx.com for latest news and status updates.