Archive for August, 2009



Check for checkbox’s [PHP]

To check which checkbox is selected, or if both are selected, in PHP
<input type="checkbox" name="coupons[]" value="1" >
<input type="checkbox" name="coupons[]" value="2" >
checker in php
if (isset($_POST[’Submit’])) {
$state=$_POST[’coupons’];
foreach ($state as $statename)
{
$x = $statename;
$ugh .= $x;
}
if 1 is selected, result will be 1
if 2 is selected result will be 2
if both are selected, result will be 12
go forward using [...]

If you need to add several emails, to refer a friend without asking the user to add all in separated by commas !
Code below provides separate field, where user can add individual email and press ADD, emails are then added automatically, separated by a comma “,” . There is an extra comma at the end [...]

Removing duplicates from several CSV/Excel files.

One can use ‘remove duplicates’ in excel but what if there are over 200k records, split into several csv files/spread sheets.
Easiest solution is to upload to database and add a checking method before hand.
1-Check if email already exists in table
2-If email does not exist then add email to table
<?php
ini_set(’max_execution_time’, 0);

//connect to database/table

$array = file("1.csv");
foreach ($array [...]