// echo "<script> alert('Upload Failed'); </script>"; $errMsg .= "Upload Failed"; } else { if (move_uploaded_file($_FILES["csvFile"]["tmp_name"], $target_file)) { // echo "<script> alert('Upload Success'); </script>"; echo "<form method='POST' action='submit_import_file.php'>"; echo "<table id='importTable' class='table table-condensed table-hover'>"; echo "<thead>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<th> No. </th>\n\t\t\t\t\t\t\t\t\t\t\t<th> Reaction Information </th>\n\t\t\t\t\t\t\t\t\t\t\t<th> Suspected Drug (s) Information </th>\n\t\t\t\t\t\t\t\t\t\t\t<th> Reporter information </th>\n\t\t\t\t\t\t\t\t\t\t\t<th> Primary Source Information </th>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</thead>"; echo "<tbody>"; $file = fopen($target_file, "r"); $errCount = 0; $line = fgetcsv($file); $c = 1; while (($line = fgetcsv($file)) !== false) { echo "<tr>"; $formID = formIDGenerator(); // foreach($line as $cell) // { // echo "<td>".htmlspecialchars($cell)."</td>"; // } if (count($line) != 38) { // die("lolll"); // echo "Error detected"; $errCount++; } else { echo "<td> {$c} </td>"; echo "<td style='vertical-align:top'><b> ADR No: </b> <input type='text' name='formID[]' value='{$formID}' class='form-control' readonly />Patient Initials: <input type='text' name='ptInitial[]' value='" . $line[0] . "' class='form-control' readonly/> <input type='hidden' name='ptDOB[]' value='" . $line[1] . "'/> <input type='hidden' name='ptAge[]' value='" . $line[2] . "'/> <input type='hidden' name='sex[]' value='" . $line[3] . "'/> <input type='hidden' name='rt1stTimeDate[]' value='" . $line[4] . "'/> <input type='hidden' name='seriousnessCrit[]' value='" . $line[5] . "'/> <input type='hidden' name='seriousnessCritOtr[]' value='" . $line[6] . "'/> <input type='hidden' name='adrDesc[]' value='" . $line[7] . "' class='form-control dtf'/> </td>"; echo "<td style='vertical-align:top'>Characteristic: <input type='text' name='charac[]' value='" . $line[8] . "' class='form-control' readonly /> Product Name: <input type='text' name='prdctName[]' value='" . $line[9] . "' class='form-control' readonly /> <input type='hidden' name='actvIngredient[]' value='" . $line[10] . "' /> <input type='hidden' name='dose[]' value='" . $line[11] . "' /> <input type='hidden' name='doseUnit[]' value='" . $line[12] . "' /> <input type='hidden' name='doseInterval[]' value='" . $line[13] . "' /> <input type='hidden' name='doseIntervalUnit[]' value='" . $line[14] . "' /> <input type='hidden' name='cumDoseDay[]' value='" . $line[15] . "' /> <input type='hidden' name='cumDoseDayUnit[]' value='" . $line[16] . "' /> <input type='hidden' name='routeOfAdmin[]' value='" . $line[17] . "' /> <input type='hidden' name='indication[]' value='" . $line[18] . "' /> <input type='hidden' name='theraphyStartDate[]' value='" . $line[19] . "' /> <input type='hidden' name='theraphyStopDate[]' value='" . $line[20] . "' /> <input type='hidden' name='reacSubsided[]' value='" . $line[21] . "' /> <input type='hidden' name='reacReapp[]' value='" . $line[22] . "' /> <input type='hidden' name='history[]' value='" . $line[23] . "' /> <input type='hidden' name='relInves[]' value='" . $line[24] . "' /> </td>"; echo "<td style='vertical-align:top'>Name: <input type='text' name='rptrName[]' value='" . $line[25] . "' class='form-control' readonly /> Address: <input type='text' name='rptrAddrs[]' value='" . $line[26] . "' class='form-control' readonly /> <input type='hidden' name='dateRptRcv[]' value='" . $line[27] . "' /> <input type='hidden' name='rptrDateofRpt[]' value='" . $line[28] . "' /> <input type='hidden' name='typeOfReport[]' value='" . $line[29] . "' /> <input type='hidden' name='reportInit[]' value='" . $line[30] . "' /> </td>"; echo "<td style='vertical-align:top'>Primary Reporter Qualification: <input type='text' name='primSource[]' value='" . $line[31] . "' class='form-control' readonly /> Primary Reporter Name: <input type='text' name='rptrName[]' value='" . $line[32] . "' class='form-control' readonly /> <input type='hidden' name='rptrDesig[]' value='" . $line[33] . "' /> <input type='hidden' name='rptrState[]' value='" . $line[34] . "' /> <input type='hidden' name='rptrOrgPub[]' value='" . $line[35] . "' /> <input type='hidden' name='rptrDept[]' value='" . $line[36] . "' /> <input type='hidden' name='rptrAddrs[]' value='" . $line[37] . "' /> </td>"; $c++;
function formIDGenerator() { include "connection_pure.php"; $ret = ""; $formID = rand(100000, 2000000000); $query = "SELECT adrDataIDAI FROM adrdata WHERE adrFormID = {$formID}"; $res = mysqli_query($con, $query); if ($res) { if (mysqli_num_rows($res) > 0) { $ret = formIDGenerator(); } else { $ret = $formID; } } return $ret; }