PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Aug 20, 2017 4:54 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Nov 08, 2016 1:13 am 
Offline
Forum Newbie

Joined: Tue Nov 08, 2016 1:08 am
Posts: 1
Hi I have a student form
Syntax: [ Download ] [ Hide ]
<?php
   $fonts = "verdana";
   $fontcolor = "#3A9BE8";
   $bgcolor = "#faaa3c";
?>

<!doctype html>
<html>
<head>
   <title>Php Syntax</title>
   <style>
      body{
         font-family:<?php echo $fonts;?>
         
      }
      .phpcoding{
         width: 900px;
         margin: 0 auto;
         background: #ddd;
         
         min-height:400px;
      }
     
      .headeroption, .footeroption{
         background:#444;
         color:<?php echo $fontcolor; ?>;
         text-align: center;
         padding: 20px;
      }
      .headeroption h2, footeroption h2{
         margin:0;
      }
      .maincontent{
         min-height:400px;
         padding: 20px;
         background:<?php echo $bgcolor;?>
      }
   </style>
</head>
<body>

<div class="phpcoding">
   <section class="headeroption">
      <h2>Student Data</h2>
   </section>
   
   <section class="maincontent">      
      <div class = "student_data">
         <form action = "" method = "post">
            <table>
               <tr>
                  <td>Name</td>
                  <td><input type = "text" name = "name" /></td>
               </tr>
               
               <tr>
                  <td>City</td>
                  <td><input type = "text" name = "city" /></td>
               </tr>
               
               <tr>
                  <td>Exam Date</td>
                  <td><input type = "date" name = "examDate" /></td>
               </tr>
               
               <tr>
                  <td>Browse to upload file... </br></td>
                  <td><input type = "file" name = "browseFile" /></td>
               </tr>                          
               
               <tr>
                  <td></br></td>
                  <td><input type = "submit" name = "uploadFile" value = "Upload"/></td>
               </tr>  
               <tr>
                  <td></br></td>
                  <td><input type = "submit" name = "save" value = "Save"/></td>
               </tr>                  
            </table>
         </form>
      </div>
   </section>
   
   <section class="footeroption">
      <h4> <?php echo "&copy All rights reserved" ?></h4>
   </section>
     
</div>

</body>
</html>


I have a text file "marks.txt". the text file looks like this. 3 terms marks are there for Math, Economics & English.

Quote:
Math
80
55
90
Economics
59
22
60
English
83
68
76


I want to upload the data from this text file to MySQL table. I just need the numbers, so how can I avoid the String (Math, Economics and English).
please help me. I don't know how to get data from text file.


Top
 Profile  
 
PostPosted: Tue Nov 08, 2016 8:16 am 
Offline
Moderator
User avatar

Joined: Tue Nov 09, 2010 3:39 pm
Posts: 6268
Location: Montreal, Canada
Start here and let us know where you get stuck: http://php.net/manual/en/function.fgets.php

_________________
Supported PHP versions No longer supported versions


Top
 Profile  
 
PostPosted: Tue Nov 08, 2016 10:37 am 
Offline
Site Administrator
User avatar

Joined: Wed Aug 25, 2004 7:54 pm
Posts: 13421
Location: New York, NY, US
For the file upload, start here: http://php.net/manual/en/features.file-upload.php

Once you have uploaded the file, you can read it into an array with: http://php.net/manual/en/function.file.php

_________________
(#10850)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: Exabot [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group