 <p>When $asp is an array like this:</p> <pre><code>[0] =&gt; 1 [1] =&gt; 2 [2] =&gt; 3 </code></pre> <p>You can get the values by doing</p> <pre><code>foreach($asp as $key =&gt; $value){ echo $value; } </code></pre> <p>Since you are a lazy programmer, this is wat you can do: You want to insert $asp and $asp2 into your database if I get the question right.</p> <pre><code>$new_array = array_combine($asp,$asp2); foreach($new_array as $key =&gt; $value){ $sql = "INSERT INTO dea (did,c1, c2, timestamp) VALUES ('',$key, $value,'".date("Y-m-d H:i:s")."')"; $stmt = mysql_query($sql) or die(mysql_error()); } </code></pre> <p>And by the way, like Doon said: Your if statements doesn't make any sense.</p> <pre><code>if ($tube11==$tube11 &amp;&amp; $fan1==$fan1 &amp;&amp; $bulb1==$bulb1) </code></pre> <p>This will always be true.</p>