|  | Posted by larry on 12/11/06 21:11 
note: you need "s around days[] in your INPUT entry (name="days[]")
 The code you posted will return to the form action target an array:
 days (if any days are checked) in $_POST. This is a code snippet not
 the entire form logic, You still have to validate the POST data,
 implode and use a DB INSERT/UPDATE statement to finish it all.
 
 Here is some more code for how to bring the form data in:
 
 //this will get your days back to a local array (when you read in your
 POSTed from data, if there is no data it set up an empty array (in case
 you go back to the entry form)
 
 If isset($_POST['days']) {
 $days = $_POST['days'];
 } else {
 $days = array();
 }
 // Add validation code here...
 
 //If the data is valid, before you put it in SQL you will need to make
 your array into a string (again you should use addslashes escape any
 potentially bad data.)
 
 $sqldays = implode(",",$days);
 
 //(you would add the result string into your update/insert query for
 the days field.)
 
 //then when reading in back in from SQL (for editing):
 
 $days = explode(",",$sqlresult['daysfield']);
 
 As for complete form logic,
 Here is a write up of how to code a one file form/db handling script
 (not suited for everything but is good for single record entry/edit
 work.)
 http://www.portcommodore.com/quickpage.php?id=Single+File+Edit+Script
 
 (I havent posted the example script, should do that soon.)
 
 Larry
  Navigation: [Reply to this message] |