Posted in PHP, zebra_form

Zebra_form – uploading multiple documents or images

require “”.$_SERVER[‘DOCUMENT_ROOT’].”/xyz/Zebra_Form/Zebra_Form.php”;

$form = new Zebra_Form(‘form1’, ‘post’, ”, array(‘autocomplete’ => ‘off’));

// — _UPLOADS_MULTI ——————————————————————

$form->add(‘label’, ‘lbl_uploads_multi’, ‘_UPLOADS_MULTI’, “CESUploads”);

$obj = $form->add(‘multiplefile’, ‘_UPLOADS_MULTI’);

$myPath1 = ‘CES’ . ‘/’ . ‘Docs’;

$obj->set_rule(array(
‘upload’ => array($myPath1, false, ‘error’, ‘errUpload’),
‘filetype’ => array(‘pdf,jpg,jpeg, png’, ‘error’, ‘errFileType’),
‘filesize’ => array(2000000, ‘error’, ‘errMaxFileSize#2000000’),
‘maxfiles’ => array(50, ‘error’, ‘lblMaxFiles#50’),
));

On Submit …..

if ($form->validate()) {

$fileUploadId = $form->getUploadId();

foreach ($fileUploadId as $key => $value)

echo ‘ storeDetail (‘ . $value . ‘); ‘;

}

$form->render(‘inl_sev_057_T_opl.php’);

Posted in HTML, PHP, zebra_form

Zebra_form – viewing uploaded documents

$fileUpload = $form->getUploadDetails($uploadid); 

$myArray = json_decode(json_encode($fileUpload), True); 

$myArray = array_shift($myArray); 

$myEnv = “http://” . $myEnv;

foreach ($myArray as $key => $value) {

$myURL = substr($myArray[$key][‘path’], 5);

$mySafeURL = str_replace(‘ ‘, ‘%20’, $myURL);

$mysrc = $myEnv . $mySafeURL;

PDFandJPGandPNG

echo “<hr>”;

}

$form->render(‘inl_sev_065_T_ver.php’);

?>

Posted in PHP, zebra_form

Multiple dynamically filled zebra_form select boxes

$form->add(‘label’, ‘label_questionlist’, ”, “CESChooseaquestionfromthepool”);

for ($x = 0; $x <= 14; $x++) {

$obj = $form->add(‘select’, ‘_QUESTION_LIST’ . $x);

$obj->add_options($questionArray);

$obj->set_attributes(array(
‘class’ => ‘input-field control form-control’,
‘style’ => ‘width:500px’,
));

$obj->set_rule(array(

));

$obj->disable_spam_filter();

}

Posted in PHP, zebra_form

Multiple predefined zebra_form select boxes

$form->add(‘label’, ‘label_weight’, ”, “CESWeightin”);

for ($x = 0; $x <= 14; $x++) {

$obj = $form->add(‘select’, ‘_WEIGHT’ . $x);

$obj->add_options(array(
0 => ‘0’,
1 => ‘1’,
5 => ‘5’,
10 => ’10’,
15 => ’15’,
20 => ’20’,
25 => ’25’,
30 => ’30’,
35 => ’35’,
40 => ’40’,
45 => ’45’,
50 => ’50’,
60 => ’60’,
100 => ‘100’,
));

$obj->set_attributes(array(
‘class’ => ‘input-field control form-control’,
‘style’ => ‘width:150px’,
‘onChange’ => ‘calculatePercentage()’
));

$obj->set_rule(array(

));

$obj->disable_spam_filter();

}

Posted in PHP, SQL

Create an array from a SQL query in PHP

// — Retrieve the list of questions ——————————————

$sql = “SELECT _QUESTION FROM questions WHERE _DEPT = ‘$dept'”; 

$db = new MysqliDb(‘CES’);

$selectStatus = $db->rawQuery($sql);

$questionArray = [];

if ($selectStatus > 0) {

$tmp[‘message’] = ‘Central evaluation system – Questions loaded successfully’;
$tmp[‘success’] = ‘Y’;

foreach ($selectStatus as $row) {

$questionArray[] = $row[‘_QUESTION’]; 

}

}