コード例 #1
0
function add_students_from_csv($files)
{
    $filename = "";
    //print_r($files);
    $filename = $files["file"]["tmp_name"];
    //print_r($files);
    $options['delimiter'] = ",";
    //echo tableFromCsv($files["file"]["name"], true, $options);
    //echo "<pre>";
    $result = extractCsv($filename, true, $options);
    // echo"<pre>";print_r($result);
    //   echo "iambatman . $result";
    // print_r($result);
    $ids = array_column($result, "ID #");
    //echo "<pre>";print_r($ids);
    $keys = array_keys($result[0]);
    $check_keys = array_slice($keys, 0, 6);
    //echo "<pre>";print_r($check_keys);
    $format_key = array("ID #", "Last", "First", "Advisor", "Start SEM.", "Option");
    // echo "<pre>";print_r($format_key);
    //echo "value".($check_keys === $format_key);
    if ($check_keys === $format_key) {
        //echo "iambatman";
        $students = array();
        $counter = 0;
        // echo"<pre>";print_r($ids);
        for ($i = 0; $i < sizeof($ids); $i++) {
            $check = studentid_validation($ids[$i]);
            if ($check == "false") {
                //	echo "<br>".$ids[$i];
                $students[$counter][$i] = $ids[$i];
                $counter++;
            }
            //	echo $i."  ".$ids[$i]."<br>";
        }
        if ($counter > 0) {
            // echo"<pre>";print_r($students);
            return $students;
        } else {
            $keys = array_keys($result[0]);
            //echo "<pre>";print_r($keys);
            /*foreach ($result as $i => $values) {
            			//echo "<pre>";print_r($values);
            			add_student($values);
            		}*/
            foreach ($result as $i => $values) {
                add_student($values);
                for ($i = 6; $i < sizeof($keys); $i++) {
                    //echo $values ['ID #'].$keys[$i];print_r($values[$keys[$i]]);echo "<br>";
                    add_foundatation($values['ID #'], "GCIS " . $keys[$i], $values[$keys[$i]]);
                }
            }
            return 1;
        }
    } else {
        return 0;
    }
}
コード例 #2
0
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Tab-separated Values</title>
    <link rel="stylesheet" type="text/css" href="tabs.css">
</head>
<body>
<?php 
include '../includes/csv_functions.php';
$cars = extractCsv('cars_tab.csv', 0, "\t");
?>
<table>
    <tr>
        <th>Make</th>
        <th>Year</th>
        <th>Price</th>
        <th>Mileage</th>
        <th>Description</th>
    </tr>
    <?php 
foreach ($cars as $car) {
    ?>
    <tr>
        <td><?php 
    echo $car['make'];
    ?>
</td>
        <td><?php 
    echo $car['yearmade'];
    ?>
コード例 #3
0
                </td>
                <td>
                    <?php 
        echo $row['credit hours'];
        ?>
                </td>
            </tr>
            <?php 
    }
    ?>
        </table>
    <?php 
} else {
    echo '<p><em>Curriculum for semester 1 not available.</em></p>';
}
if ($table2 = extractCsv('../_assets/second_semester.csv')) {
    ?>
        <table>
            <tr>
                <th>Second Semester</th>
                <th>Credit Hours</th>
            </tr>
            <?php 
    foreach ($table2 as $row) {
        ?>
                <tr>
                    <td>
                        <?php 
        $space = strpos($row['Second Semester'], ' ');
        echo '<strong>' . substr_replace($row['Second Semester'], '</strong>', $space, 0);
        ?>
コード例 #4
0
?>
?>
  <?php 
$studentdata = array();
if (isset($_FILES["file"])) {
    $semester = $_POST['semester'];
    $year = $_POST['year'];
    $result = file_check($_FILES);
    if ($result == "success") {
        $dbc = dbConnect('local');
        $filename = "";
        $filename = $_FILES["file"]["name"];
        //  print_r($_FILES);
        $options['delimiter'] = ",";
        // echo tableFromCsv($filename, true, $options);
        $result = extractCsv($filename, true, $options);
        echo "<pre> batman";
        print_r($result);
        $keys = array_keys($result[0]);
        $loop = sizeof($result);
        $numkey = sizeof($keys);
        $numofstudent = -1;
        $numofcourse = -1;
        $numofgrd = -1;
        //print_r($keys);
        //echo "$loop";
        for ($i = 0; $i < $loop; $i++) {
            for ($j = 0; $j < $numkey; $j++) {
                //echo "<pre>".$keys[$j]."    ".$result[$i][$keys[$j]];
                if (!empty($result[$i]['ID']) && $keys[$j] == "ID") {
                    $numofstudent++;