Search the web
Sign In
New User? Sign Up
phpexperts
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
form generation using mysql query   Message List  
Reply | Forward Message #13229 of 13278 |
Re: form generation using mysql query


Hi Expert,

I am interested to join the application.


Regards,

Amit Bajaj
M+9718138085


--- In phpexperts@yahoogroups.com, "daniel_honrade_jr" <daniel_honrade_jr@...>
wrote:
>
> hi to all, i am developing an oop cms and part of this is form class which
generates forms automatically by just giving the mysql query
>
> function form_get($form_query = NULL, $form_name = NULL, $form_action = NULL,
$form_method = 'post', $form_cancel = 0) {
> //object oriented query
> $row = $this->dbc->query($form_query);
> $output = NULL;
> $output .= '<form action="' . $form_action . '" method="' . $form_method .
'">';
> //generate form items based on fields
> while ($field = $row->fetch_field()) {
>
> //print show_array($field);
>
> //form field error class
> isset($_SESSION[str_replace(' ', '_', $field->name)]) ? $input_class =
$_SESSION[str_replace(' ', '_', $field->name)]: $input_class = '';
> //form field default value
> isset($_POST[str_replace(' ', '_', $field->name)]) ? $field_value =
$_POST[str_replace(' ', '_', $field->name)]: $field_value = '';
> //form field password type
> (preg_match('/\s*password\s*/', $field->name)) ? $field_type = 'password':
$field_type = 'text';
> //form input/textarea type
> ($field->length > 100) ? $input_type = '<label>' . ucwords($field->name) .
'</label><textarea class="' . $input_class . '" name="' . str_replace(' ', '_',
$field->name) . '" cols="20" rows="5">' . $field_value . '</textarea>':
> $input_type = '<label>' . ucwords($field->name) . '</label><input
class="' . $input_class . '" type="' . $field_type . '" name="' . str_replace('
', '_', $field->name) . '" value="' . $field_value . '"/>';
> $output .= $input_type;
> //reset empty error class
> $_SESSION[str_replace(' ', '_', $field->name)] = '';
> }
> //cancel submit button switch
> ($form_cancel) ? $cancel = '<input name="cancel" type="submit"
value="Cancel">': $cancel = '';
> //form sumit button
> $output .= '<input type="submit" name="' . $form_name . '" value="' .
ucwords($form_name) . '" /> ' . $cancel;
> $output .= '</form>';
> return $output;
> }
>
> so far so good, all you need to give this input to generate form
>
> $form_query = 'SELECT name as user, password as "new password", password as
"retype password" FROM user LIMIT 1';
> $form_name = 'request';
> $form_action = '';
> $form_method = 'post';
> $form_cancel = 1;
>
>
> $output = $this->form_get($form_query, $form_name, $form_action,
$form_method, $form_cancel);
>
> anybody interest to join me in developing this code?
>





Wed Nov 4, 2009 6:48 am

amitmmc1
Offline Offline
Send Email Send Email

Forward
Message #13229 of 13278 |
Expand Messages Author Sort by Date

hi to all, i am developing an oop cms and part of this is form class which generates forms automatically by just giving the mysql query function...
daniel_honrade_jr
daniel_honra...
Offline Send Email
Oct 26, 2009
9:19 am

yap Tanvir...
tanvir
tanvir_064
Offline Send Email
Oct 27, 2009
7:13 am

Daniel, I've written similar code for Ladder. It pulls the object structure from the data store, and generates a generic form. Interested in looking at that? ...
Michael
enetarch
Online Now Send Email
Oct 31, 2009
4:50 am

hi can u share your code to me, so I can study them? Daniel Honrade, Jr. mobile:  +63 915 903 3561 alternate email:  mail@... website:  ...
Daniel Honrade
daniel_honra...
Offline Send Email
Nov 5, 2009
9:55 am

Hi Expert, I am interested to join the application. Regards, Amit Bajaj M+9718138085...
Amit
amitmmc1
Offline Send Email
Nov 4, 2009
6:59 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help