Instead of storing whole form pattern (and values) in the db field i can advise you to store only form field names and data (values) as key-value pairs.
You can easily use them if you store them in a standard way like ;
(use at form processing page)
$form_data = "my-item-id=".$_POST["my-item-id"]."&my-item-name=".$_POST["my-item-name"]."&my-item-price=".$_POST["my-item-price"]."&my-item-qty=".$_POST["my-item-qty"];
then store $form_data only at db
to use data from db (surely after pulling $form_data from db) you can use parse_str
parse_str($form_data,$form_data_from_db);
echo $form_data_from_db["my-item-id"] will print your stored form input for instance
But these are not the my main advice.
How you will build your pattern for each stored data field?
Just build a function to create form like many cms does.
try this ;
function myform_pattern_1($id,$method,$action,$class,$form_data){
parse_str($form_data,$fd);
$form_html = "<form id='' method='' action='' class=''>";
$form_html .= "<input type='hidden' name='my-item-id' value='".$fd["my-item-id"]."' />";
$form_html .= "<input type='hidden' name='my-item-name' value='".$fd["my-item-id"]."' />";
$form_html .= "<input type='hidden' name='my-item-price' value='".$fd["my-item-id"]."' />";
$form_html .= "<input type='hidden' name='my-item-qty' value='".$fd["my-item-id"]."' />";
$form_html .= "<input type='submit' name='my-add-button' class='button' value='Add to cart'/>";
$form_html .= "</form>";
return $form_html;
}
Call this function where you like as ;
echo myform_pattern_1("form_id","post","","form_class",$form_data);
This usage has a great advantage to your method.
You can change form syntax whenever you wish this way. You will -maybe- want to integrate a Jquery validation plugin later or just want to use another styling or even change syntax by adding tags you will have to change all stored db fields if you store whole form at db. Function usage is much more flexible.Also you will not use db for storing unnecessary -repeating- tags etc.
i hope you like , cys
For more information on parse_str ; http://php.net/manual/en/function.parse-str.phpenter code here