Annulleret

Script modification

This is a very simple $10 project:

Just need a very simple script modification. Script downloads data from our database making changes to content / replace text on download.

I need to add a section where it will automatically remove any from the database (so for example the name OConnor becomes OConnor.

I try to do

switch ($row['vLastName']) {

case '' :

$row['vLastName'] = '';

break;

case "0-0-0": $row['vLastName'] = "00/00/00";

}

but because is code, it causes syntax error.

Need a quick fix... Full script below.

$where = '';

if($_POST['vPTitle'] != '')

$where .= 'and vPTitle LIKE '%'.$_POST['vPTitle'].'%' ';

if($_POST['answer'] != '')

$where .= 'and vCAnswer LIKE '%'.$_POST['vCAnswer'].'%' ';

if($_POST['start'] != '' && $_POST['end'] != ''){

$ar = explode('/',$_POST['start']);

$start = $ar[2].'/'. $ar[1].'/'. $ar[0];

$ar = explode('/',$_POST['end']);

$end = $ar[2].'/'. $ar[1].'/'. $ar[0];

$where .=" and dDate BETWEEN '".$start."' AND '".$end."' ";

}

$csv_output = '"TITLE","FIRST","LAST","ADDR1","TOWN","POSTCODE","DAYPHONE","MOBPHONE","EMAILADDR","DOB","GENDER","NI_EMAIL_PERMISSION","NI_SMS_PERMISSION","NI_POST_AND_PHONE_PERMISSION","TRD_PARTY_POST_AND_PHONE_PERMISSION","BUY_TIMES","SAT_TIMES","BUY_STIMES","CODE","RECENCYDAT"';

$csv_output .= "rn";

$result = mysql_query("SELECT * , DATE_FORMAT(dDate, '%d/%m/%Y') as register_date FROM promotion_user_2 WHERE iPromoUId > 0 $where ");

if(@mysql_num_rows($result) != 0){

while($row = mysql_fetch_assoc($result)) {

foreach($row as $ind => $val){

$row[$ind] = str_replace('"', '', $row[$ind] );

$row[$ind] = str_replace(',', ' ', $row[$ind] );

$row[$ind] = str_replace('s', 's', $row[$ind] );

}

switch ($row['vGender']) {

case 'Male' :

$row['vGender'] = 'm';

break;

case 'Fale' :

$row['vGender'] = 'f';

break;

default:

$row['vGender'] = 'u';

}

$row['eEmail'] = ($row['eEmail']== 'Yes' ? 3 : 4);

$row['eSMS'] = ($row['eSMS']== 'Yes' ? 3 : 4);

$row['eContactedByUs'] = ($row['eContactedByUs']== 'Yes' ? 4 : 3);

$row['eSelectedCompanies'] = ($row['eSelectedCompanies'] == 'Yes' ? 4 : 3);

switch ($row['vReadNewspapper']) {

case "1-3 TIMES PER WEEK": $row['vReadNewspapper'] = "QO";

break;

case "4-6 TIMES PER WEEK": $row['vReadNewspapper'] = "AA";

break;

case "LESS THAN ONCE A WEEK": $row['vReadNewspapper'] = "OO";

break;

case "NEVER": $row['vReadNewspapper'] = "NO";

break;

}

switch ($row['vReadOnSaturday']) {

case "1-2 TIMES PER MONTH": $row['vReadOnSaturday'] = 2;

break;

case "3-4 TIMES PER MONTH": $row['vReadOnSaturday'] = 4;

break;

case "LESS THAN ONCE A MONTH": $row['vReadOnSaturday'] = 2;

break;

case "NEVER": $row['vReadOnSaturday'] = 0;

break;

}

switch ($row['vReadOnSunday']) {

case "1-2 TIMES PER MONTH": $row['vReadOnSunday'] = "QO";

break;

case "3-4 TIMES PER MONTH": $row['vReadOnSunday'] = "AA";

break;

case "LESS THAN ONCE A MONTH": $row['vReadOnSunday'] = "OO";

break;

case "NEVER": $row['vReadOnSunday'] = "NO";

break;

}

switch ($row['dBirthDate']) {

case '-' :

$row['dBirthDate'] = '/';

break;

case "0-0-0": $row['dBirthDate'] = "00/00/00";

}

$csv_output .= '"'.$row['vTitle'].'","'.$row['vFirstName'].'","'.$row['vLastName'].'","'.$row['vHouseNo'].' '.$row['vStreet'].'","'.$row['vCity'].'","'.$row['vPinCode'].'","'.$row['vTelNo'].'","'.$row['vMobileNo'].'","'.$row['vEmail'].'","'.$row['dBirthDate'].'","'.$row['vGender'].'","'.$row['eEmail'].'","'.$row['eSMS'].'","'.$row['eContactedByUs'].'","'.$row['eSelectedCompanies'].'","'.$row['vReadNewspapper'].'","'.$row['vReadOnSaturday'].'","'.$row['vReadOnSunday'].'","'.$row['vPTitle'].'","'.$row['register_date'].'"';

$csv_output .= "rn";

}

$csv_output = str_replace("'", "", $csv_output);

header("Content-type: application/vnd.ms-excel");

header("Content-disposition: attachment; filename=".date("Y-m-d")."_Promo2.csv");

print $csv_output;

exit;

} else {$err = 'No members were found with xcode "'.$_POST['vPTitle'].'" ';}

}

?>

<HTML>

Færdigheder: PHP

Se mere: break fix, c ar, val , syntax, rn, postcode, php ar, modification , exit, ar, break times, content disposition, section script, excel script simple example, excel header fix, replace text html, simple script excel, php header script, remove script, switch application, csv excel text, php print error, text row, application downloads, val date

Om arbejdsgiveren:
( 70 bedømmelser ) london, United Kingdom

Projekt-ID: #280662