Jump to content

Recommended Posts

Hello all,

 

I have an order form that is built dynamically from my products database and would like to create a dynamic validation and form processor.

 

I have created a good validation scheme by hardcoding the names of the fields from the orderform, an example is as follows

 

$two_a = $_POST['PROD_cub_bear_patch_3x3_4'];

$two_b = $_POST['PROD_cub_bear_patch_special_10'];

$two_c = $_POST['PROD_cub_club_patch_3'];

 

The names like PROD_cub_bear_patch_3x3_4 are stored in fields in a database corresponding to their appropriate product and can be easily retrieved. I would like to make a while loop that goes through the database and creates the variable dynamically from the post based on whats in the database.

 

A possible solution is as follows

 

$result = @mysql_query('SELECT * FROM products WHERE category AND status="1"');

while ($row = mysql_fetch_array($result)) {

$name = $row['name'];

echo '$'.$name.' = $row[/''.$name.'/'];';

}

 

*NOTE: $name is the name of the product field that is stored in the database

 

I'm not sure how to make this work and would be really appreciative of any input/insight that any of you may have.

 

Thanks in advance.

 

Jordan

Link to comment
https://forums.phpfreaks.com/topic/49271-solved-validation-for-a-dynamic-form/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.