troubleshooting Question

C-R-U-D CSV file

Avatar of debtonu sarkar
debtonu sarkar asked on
PHP
7 Comments4 Solutions684 ViewsLast Modified:
I have a csv file. i need to read it which i already done but cannot edit it and also need to delete a particular line....  Can anybody help me for doing this......

the csv file is given bellow
https://drive.google.com/file/d/0B-9jQIuzx-JYYjlBZTFaX3JWN28/view?usp=sharing

and the read code is also given bellow with in table format:
<html>
    <head>
        <title>Reading Form Csv File Training</title>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

    </head>
    <body>
        <div class="container">
            <div class="col-sm-3"><h1>Pages</h1></div>
            <div class="col-sm-3"><a href="index.php"><h2>Web1</h2></a></div>
            <div class="col-sm-3"><a href="p1.php"><h2>web1-fino-al-20170105</h2></a></div>
            <div class="col-sm-3"><a href="p2.php"><h2>web1-fino-al-20151118</h2></a></div>
            <table class="table table-striped">
                <thead>
                <th>No</th>
                <th class="text-center">Data 1</th>
                <th class="text-center">Data 2</th>
                <th class="text-center">Data 3</th>
                <th class="text-center">Data 4</th>
                <th class="text-center">Data 5</th>
                <th class="text-center">Data 6</th>
                <th class="text-center">Data 7</th>
                <th class="text-center">Data 8</th>
                <th class="text-center">Data 9</th>
                <th class="text-center">Data 10</th>
                <th class="text-center">Data 11</th>
                </thead>
                <?php
                $row = 1;
                if (($handle = fopen("csvfile/web1-fino-al-20151118.csv", "r")) !== FALSE) {
                    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                        $num = count($data);
                       
                        for ($c = 0; $c < $num; $c++) :
             
                            $va = explode(";", $data['0']);
         
                            $cx = 0;
                            ?>
                            <tr>
                                <td class="text-center"><?php echo $row; ?></td>
                                <?php
                                for ($cx = 0; $cx < count($va); $cx++) {
                                    ?>


                                    <td class="text-center"><?php echo $va[$cx]; ?></td>



                                    <?php
                                }
                                ?>
                                <td><button type="button" class="btn btn-warning">Edit</button></td>
                                <td><a href="deletecsvline.php?$data['0']=<?php echo $data['0'] ?>"<button type="button" class="btn btn-danger">X</button></a></td>
                            </tr> 
                            <?php
                        endfor;
                        $row++;
                    }
                    fclose($handle);
                }

                ?>

               
            </table>
        </div>
    </body>
</html>



waiting for help
SOLUTION
gr8gonzo
Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros