How to store $_POST data in an array and access it with foreach and save into mysql
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3489387/php-post-print-variable-name-along-with-value">PHP $_POST print variable name along with value</a>  </p>
</blockquote>



<p>I am just wondering how to store $_POST variables in an array.</p>

<p>I have several $_POST variables, as follows:</p>

<pre><code>$_POST['cCode'];
$_POST['sSubject'];
$_POST['lect'];
$_POST['rRoom'];
$_POST['dDay'];
$_POST['sTime'];
$_POST['eTime'];
</code></pre>

<p>How can I access them all at the same time using a <code>foreach()</code>?</p>

<p>I know how to access one, like this:</p>

<pre><code>   $data = $_POST['cCode'];
    foreach($data as $code){
        echo $code;
    }
</code></pre>

<p>Then I want to save it into mysql..</p>

<p>Here is my database: </p>

<pre><code>DROP TABLE IF EXISTS `ocs_database`.`schedule`;
CREATE TABLE  `ocs_database`.`schedule` (
  `schedID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `courseCode` varchar(30) NOT NULL,
  `subjectName` varchar(45) NOT NULL,
  `roomName` varchar(45) NOT NULL,
  `lecturerName` varchar(45) NOT NULL,
  `day` varchar(45) NOT NULL,
  `startTime` varchar(45) NOT NULL,
  `endTime` varchar(45) NOT NULL,
  PRIMARY KEY (`schedID`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=latin1;
</code></pre>
