|
|||||||
New to SitePoint Forums? Register here for free!
|
|
|
Thread Tools | Display Modes |
|
|
#12 |
|
SitePoint Wizard
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Oct 2006
Posts: 4,201
|
OK.
1. Call your form elements the same name as the database columns, its less confusing, not doing so does not protect your database in any way, and it opens up the way to think of your code as arrays. 2. Have an array of elements you expect to find coming from your form 3. Create the start and end of the sql query 4. Loop through the elements, check they are permitted, check they are valid, if so add then to a string, and add between the start and end of the sql query. This is a simplified version with just 2 elements. PHP Code:
There are other things to be done, and I left it verbose so you can hopefully see what is going on and see what else has to be done like check there is more than just "id" set in the POST vars but this should give you an idea of how to build up the query string. The key is to marry var names to column names, and start to think about your code as arrays as spelt out by this guy in loops are good |
|
|
|
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 00:10.









Threaded Mode