Current location: Hot Scripts Forums » Programming Languages » PHP » Php custom Form


Php custom Form

Reply
  #1 (permalink)  
Old 01-23-12, 11:26 AM
smithygotlost smithygotlost is offline
Aspiring Coder
 
Join Date: Jul 2006
Location: United Kingdom
Posts: 412
Thanks: 12
Thanked 3 Times in 3 Posts
Php custom Form

Hey guys,

What im trying to do is allow a user to customize the forms they have to input data ( in this case for a stock sheet ) so they can go to a certain page and add say Barcode to it, when they then add an item an input field called bardcode exists.

The above i have done. the issue is how to store it. i thought of making a table called items, having 1 numbers than defines all of it i.e 1 then having optionid ( i.e 1 = name 2 = barcode) then value of that field

I currently have all the fields stores in catform like this

formid
value
type
catid
clientid

then when building the form i use

PHP Code:



<?php
$catid 
$_GET["catid"];
if(isset(
$catid)){
$catform mysql_query("select * FROM `ci_catform` WHERE `catid`='$catid'");

?>

   
                    <div>
                    
<?php

                        
while ($row mysql_fetch_assoc($catform)) {
                            echo
'
                        <div class="'
.$row['type'] .'Field">
                        
                            <div>'
.$row['value'] .':</div>
                            
                            <input type="'
.$row['type'] .'" name="'.$row['formid'] .'" value="" />
                        
                        </div>

                                '
;
                        }

?>
Now this builds the form perfectly.

its just taking said info processing it and storing it. Any ideas ?

Cheers
Mike
__________________
Make People Friendly Say " Thanks "
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-24-12, 03:35 AM
alxkls alxkls is offline
Newbie Coder
 
Join Date: Nov 2011
Posts: 75
Thanks: 0
Thanked 6 Times in 6 Posts
Well as far as I was able to work out your problem you are having difficulties posting the information. If that is te case i see a few problems:
1.you are missing form opening and closing tag(in your case you need one before the while loop and one after it) which will take the user input somewhere.
2.this is a dynamic form meaning that you might add new inputs in the database at any gievn time. Which means that your inserting method will skip the new once if it's a single "insert into sometable" query. So what you could do is store each input in a separate row. your option is to organize your database like
id, user_id, some_stock_id_or_whatever, input

then assuming it wont be 5000 inputs each time you could do something like
Code:
foreach ($_POST as $r)
mysql_query("insert into mytable (user_id, some_stock_id_or_whatever, input) values ('some_id', 'some_stock_id', '".$r."')");
thats just a quick reply really so you might need to fix it up a bit but that should give you a headstart... if that's of course what you are trying to achieve....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP!!!! Problem with my MySQL connected PHP login form :'( Ross_B_00 PHP 0 08-19-11 05:12 AM
ASP or PHP which is better? nepala The Lounge 9 07-14-10 06:48 AM
PHP Programmer - Form Metic Job Offers & Assistance 13 06-29-06 08:03 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
Form Submission, PHP Coding Problem kibby67 PHP 3 12-02-04 02:13 PM


All times are GMT -5. The time now is 01:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.