hi,
i have been scouring the internet lately trying to look for an answer to my question, but im at a loss, i kno whteres a way of doing what i want, im just not sure how to go about it.
so here goes, i hope somebody out there can help...
my question is how do i go about making one fnction which inserts posted values into a database, im sick of writin gth esame code over and over and just chnaging the values of the form,
this is what i have atm...
PHP Code:
$sql = "INSERT INTO $table (first,second,company,home,mobile,fax,email,address,comments) VALUES ('$first', '$second', '$company', '$home', '$mobile', '$fax', '$email', '$address', '$comments')"; } $result = mysql_query($sql); echo "You have added that record! "; //end code
as you can see the php is ok, bt to repeat this over and over is really getting on my nerves.
isnt the a way for example of doing it this way...
PHP Code:
$sql = "INSERT INTO $table ($names) VALUES ('$values')"; } $result = mysql_query($sql); echo "You have added / edited that record!";
then the sql command is generic and would work for all forms i create, how would i go about getting my form values and field names stored into arrays to do such a thing?
i have searched other forums, and i came across somethign tha tlooked ideal for me...
http://forums.devnetwork.net/viewtopic.php?t=30683
i cannot get it to work at all tho, if ayone out there is capable of giving me a working example including form and where it goes to etc i would be extremely grateful
help would be really appreciated.
phase