Generating A Table Into A File In CSV Format - and letting user download the file

free web hosting
Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Generating A Table Into A File In CSV Format - and letting user download the file

abhiram
I'm working on a project, part of which consists of working with large tables of different kinds. Now, I'm using a page seeking technique which allows you to browse through the records depending on which page you want to see and how many records you want to see on each page.

Now, I need a link (or a form button) on each page which, when clicked, will throw a file to the user for download (the download window should popup immediatly) which will give the part of the table, currently being viewed, in CSV format.

One way I can think of to generate the file is manually, that is, open an empty file in a temp directory and output everything into it using 'fwrite' in the way I want it. Is there any PHP or MySQL function which gives it directly?

But, how do I get the user to download this file? I want it to immediatly open the download window saying "Do you want to download this file" as it does in firefox, rather than take him to another page with a link to the file.

Any ideas?

Thanks.

Reply

sid.calcutta
Here is a PHP Script which may help you.

First of all, Let us create a table named tbl_test in a MySQL Database. The table contains three fields:

1. field_id
2. category
3 description

Now here is the CREATE TABLE CODE for you.

First of all, we'll drop Table, if it exists.

CODE
DROP table if exists `tbl_test`;


Now we'll create the table tbl_test.

CODE
CREATE TABLE `tbl_test` (
  `field_id` int(11) NOT NULL auto_increment,
  `category` char(20) default 'General',
  `description` char(100) default 'Not Specified',
  PRIMARY KEY  (`field_id`)

)


Now insert some test data in the table.

Now is the time to play with the following PHP Script.

The script starts at this point.

CODE
<?php

        global $db_name,$db_host,$db_user_name,$db_pass;
        $db_name='test';                
        $db_host='localhost';
        $db_username='test';
        $db_pass='test';


Connecting to Database:
CODE
    $new_file="myfile.csv";  

Consider giving a dynamic file name rather than a static one.
This is the file that will store the fetched data.

Create a file using fwrite():

CODE
$fp=fopen($new_file,"w");
             if(!$fp) die("Error creating file");
          


It will be used later on to store the fetched records.

CODE
             $link_id=mysql_connect($db_host, $db_username,$db_pass);

    if(!$link_id)  die("connection failed");


Hopefully you can add a more appropriate error handler.

Setting the current database:

CODE
$current_db=mysql_select_db($db_name,$link_id);

                    if(!$current_db) die("error connecting host");


Creating a HTML table
CODE
    echo "  <table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"0\">";

        echo "<tr>";


The table will hold a form which will display the options ( i.e. category as in my example).
Your users will choose a value from the options given.
CODE

        echo "<td><form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\"    action=\"$PHP_SELF\">";
            
                    echo "<p>Please select a category </p>";

Now selecting the records ( i.e. category) one after another from the category table and displaying it in a list box

CODE
                    echo "<select name=\"category\" size=\"1\">";
                            
              $search_string="SELECT DISTINCT category FROM tbl_test";
              $result_of_search_string=mysql_query($search_string);
              
              while($data_search_string=mysql_fetch_row($result_of_search_string))  
                
                {
                
                echo "<option> $data_search_string[0] </option>";
                
                }
                
         echo "</select>";


A simple one line instruction for the user:

CODE
echo "Click here to start :";


CODE
echo "<input type=\"submit\" name=\"Submit\" value=\"search\">";
             echo "</form>";
             echo"</tr>";

The FORM ends at this point Note the action attribute of the FORM tag set to $PHP_SELF
So when the user clicks on the submit botton the same page reloads with a value saved in the $category variable.
Now we'll show the record based on the options chosen by the user.


CODE
echo "<tr><td><h2> Your records </h2></td></tr>";




Let us set few global variables.
CODE
   global $records_per_page, $cur_page, $PHP_SELF,  $search_category, $category;


Checking if $category variable stotes any value or not, if it does not, we set it to default : General/ Or any value you prefer, but it must be the one of the values you have entered in the category field of your table.

CODE
   if(empty($_POST["category"]))     
       $search_category="General";            
   else
      $search_category=$_POST["category"];


Checking is done. Now we'll show the user, what value he wanted to see.

CODE
echo "You are searching for $search_category";



Now counting the number of records found in the database for that category:

CODE
$count_query="select count(*) from tbl_test where category = '$search_category' ";


CODE
    $result = mysql_query($count_query);
       if(!$result) die("error");
      
                $query_data = mysql_fetch_row($result);

                $total_record = $query_data[0];
                if(!$total_record) die('No Record Found!');


Now setting the page number.
CODE
$page_num = $cur_page + 1;

Now setting the maximum number of records to be displayed in one page:

CODE
   $records_per_page=10;


You can use another form to allow the user to select the records per page as we have done for selecting the category from the table.

Now we are calculating the total number of pages.
CODE
$total_num_page = $last_page_num
                   = ceil($total_record/$records_per_page);



CODE
echo "<tr><td><CENTER><H3>$total_record found on $search_category - Displaying the page
                     $page_num out of $last_page_num.</H3></CENTER>\n</tr></td>";


Now set the current page number. To start with it will have a value = 0.
CODE
if(empty($cur_page))
     {
      $cur_page = 0;
       }


Now we set the limit for the records to be displayed per page.

CODE
$limit_str = "LIMIT ". $cur_page * $records_per_page .
                                     ", $records_per_page";
                $new_query="SELECT description FROM tbl_test where category LIKE '$search_category'";
  
               $query=$new_query ." ". $limit_str;                    


Again a database query to fetch the records as per the option selected by the user. And display the records in a table.

CODE
         $result = mysql_query($query);  
          if(!$result) die("No record found");
    
        
     while($data=mysql_fetch_row($result))  
      {  
    
         echo " <tr><td> $data[0] </td></tr> ";      // this will show records
         fwrite($fp,$data[0]);             // this will write to the file
         fwrite($fp,",");             // This is the ", " seperater
    
     }


We have finished fetching records and at the same time stroring it in a file.
Now we are creating links for the user to nevigate to continuation pages.

CODE
    if($page_num > 1)
    {
      $prev_page = $cur_page - 1;

      echo "<A HREF=\"$PHP_SELF?&cur_page=0\">[Top]</A>";

      echo "<A HREF=\"$PHP_SELF?&cur_page=$prev_page\">[Prev]</A> ";
   }
   if($page_num <  $total_num_page)
   {
      $next_page = $cur_page + 1;
      $last_page = $total_num_page - 1;

      echo "<A HREF=\"$PHP_SELF?&cur_page=$next_page\">[Next]</A> ";

      echo "<A HREF=\"$PHP_SELF?&cur_page=$last_page\">[Bottom]</A>";
   }



Now we'll allow the user to download the file.

CODE
echo "<tr><td><a href =\"$new_file\">Click here to download</a>";


Our task is over. Now some closing HTML tags again.
CODE
echo" </Td>";
  echo " </tr>";
  echo "</table>";

?>


So far as the present script is concerned, I got a great help from a book entitle BEGINNING PHP4 published by Wrox Press Ltd. Infact page transition part has actually been scripted in that great book. It works nicely.

Regards,
Sid

 

 

 


Reply

Quatrux
QUOTE(abhiram @ Mar 12 2006, 01:21 PM) *

But, how do I get the user to download this file? I want it to immediatly open the download window saying "Do you want to download this file" as it does in firefox, rather than take him to another page with a link to the file.

Any ideas?

Thanks.


To force the download is quite easy, you just need to send the right headers to the browsers

CODE

        header('Content-Encoding: none');
            header('(anti-spam-content-type:) application/force-download');
            header('Content-Disposition: attachment; filename="'.$file.'.csv"');
            header('Cache-Control: must-revalidate, post-check="0", pre-check="0"');
            header('Content-Length: '.filesize($file.'.csv'));
            /* Output the File to User */
            set_time_limit(0);
            readfile($file.'.csv');
            exit;


Just fix the variables you need, like if it is not going to be a file, don't use filesize() instead use strlen(), Well I think you only needed to know the Content-type of the force download, as I remember it works on all browsers I tested, except for old versions of IE. Be careful if you are using output_buffering, before the headers always do a ob_end_clean(); if you do. wink.gif

Reply

abhiram
Hey Sid,

Whew ... took quite some time to digest everything you said. You've infact given the entire framework, in astonishing accuracy, of exactly what I've done so far minus the file part. Thanks for taking the time to reply in such detail. I appreciate it.

Now, you mean to say that it should output the records both, to the browser and also to a file simulataneously. Wouldn't this put unnecessary load on the server? The person using the system will definitely not need to download every page that he views and there are about 5000 records in all. If he chooses to 'view all' records, it'll take more time to display it since it's printing it to 2 places.

One way to do what I want is to maybe have a link that passes the exact database query that the current page uses to another php page, which will simply write everything into a file and present a link on the next page for the user to download. Then I can have another link that'll take him back to the page he was viewing. Or maybe I can just open another browser window and give him the link so that he can just close the window to go back to the previous one.

But, that's not what I would 'like' to do. I want a link or a form button on every page which when clicked, will send the output to a file and throw the file to the user, WITHOUT any change in what's being shown on the screen.

I hope you get the point.

@Quatrux:

Thanks, but I want the user to be able to get the file without changing the current screen.

Obviously, headers work only if used in the beginning of a particular page which means providing a link to another page and that's not exactly what I'm looking for.

Reply

Quatrux
Err, you will push the button to start the download and your page won't change, you'll see the same page and a window will appear which will say save/open wink.gif

Well, you could make it with AJAX, but I am still not good at it, just played with the forms, don't know much javascript, but you could send an xml request which also would force the download by the same headers I think.

That is why I am using output buffering to have no problems with headers, sessions and cookies etc. ob_start() is great, besides you can control a lot of output too.

Reply

sid.calcutta
QUOTE(abhiram @ Mar 14 2006, 09:35 AM) *

..... I want a link or a form button on every page which when clicked, will send the output to a file and throw the file to the user, WITHOUT any change in what's being shown on the screen.


Try this one line Javascript code. Place this code at the end of dynamically generated pages.( i.e., once the WHILE LOOP for fetching record is complete)
CODE

<a href="#" onClick="window.open('/downloader.php?query=<?php echo $sql?>','mywindow','width=400,height=350,left=300,top=300,screenX=300,screenY=300')">Down load CSV!</a>


To run this Javascript code accurately, just copy and paste the code as it appears here. Otherwise, you will have to waste too much time in getting the required output just like me!
This will open a new window containing the page downloader.php and a query string $query which will contain the query to be executed later on.

In the downloader.php file, just get the required query using:
CODE
$query=$_GET["query"];


Now connect to the Database as before. Fetch required records using $query, put it in the CSV file ( i.e. $new_file, as mentioned earlier) .
Finally, in the same downloader.php file, put a line of code which will allow your visitor to download the selected records in CSV format.

CODE
echo "<a href =\"$new_file\">Click here to download</a>";


Please let me know whether it worked for you or not.
Regards,
Sid


Reply

abhiram
Well, that's very clear explanation. Thanks, I think I'm gonna use this method. I didnt' want the popup window actually, but I guess it's the simplest way to get it done without killing too many brain cells wink.gif.

I'm a little tied up right now, but, the moment I find time, I'll implement this and let you know how it works out.

Thanks smile.gif.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

Similar Topics

Keywords : generating, table, file, csv, format, letting, user, download, file

  1. How To Include A File Using Absolute Paths Under A Secure Php Installation
    Alternatives to the Include() Function (6)
  2. Myspacetv Download Php Script Help
    (6)
    I was trying to make a php script that can view myspace videos with jw flv player and wont to know
    how to do so if i put in
    "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=38105626" it show the video
    "http://cache01-videos02.myspacecdn.com/11/vid_e382054c036835500bacfef1ebb5157e.flv(its the flv
    video file from myspacetv), I cant see the similarity with the links please help, thanks for viewing
    this topic /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />....
  3. How To Create/edit/delete Ftp Accounts With Php
    Help me to create one php page to create FTP user accounts in Unix Ser (2)
    Thanks /cool.gif" style="vertical-align:middle" emoid="B)" border="0" alt="cool.gif" /> ....
  4. Make A Script Run Even If No User Is Online
    (6)
    Hey! Is there any way to make a script run, even if no user is online. Because at the moment, my
    scripts run, only when a user is online. And another thing: How can i make the following: (this is
    just an example) mysql_query"SELECT maxhp FROM users WHERE username = 'allusers'"; How can I
    select all users maxhp, in the same query? Thanks //Feelay....
  5. Letting Users Add Mysql Data With Php
    (1)
    I'm curious as to the best methods of letting users submit data to a MySQL database, displaying
    that data, and removing any unwanted tags etc. from it. Currently, there's a handful of PHP
    functions that I know of to help with this: mysql_real_escape_string() - perhaps the best known
    and most commonly used function, it should be used in pretty much any MySQL query. It escapes
    characters that have SQL significance. QUOTE(php.net) ...which prepends backslashes to the
    following characters: \x00, \n, \r, \, ', " and \x1a I like to think I made a pretty....
  6. Automated Product Suggestion Script
    Compare user lists and suggest related items based on pattern matching (2)
    I recently got an idea for a project and one of the features I wanted the project to have was an
    automated suggestion service. If anyone has been to Amazon, it would work much like their
    recommended product feature. What I want to do is take several users lists of whatever but for this
    example, I'll use web links like from the browser history. I would want to suggest links to a
    user based on common links in many other users lists. User A: Amazon, Ebay, Excite, Google, Yahoo,
    MySpace, Walmart User B: Amazon, Ebay, Google, Yahoo, You Tube, MySpace, CVS User C: Amazo....
  7. Extplorer
    A PHP -and JavaScript- based File Manager (7)
    Browsing the ExtJS examples website i found this excellent web-based file manager called
    eXtplorer . eXtplorer allows you to browse your webserver folders with an intuitive Layout which
    makes working with files very easy, and thanks to the great ExtJS Javascript Library you can drag
    & drop folders and files, filter directories and sort the file list using various criteria. You can
    use eXtplorer to for example: browse directories & files on the server. edit, copy, move, delete
    files. search, upload and download files. create and extract archives. create new fil....
  8. Php File Upload
    About uploading files through php (3)
    Right i have done a check for a tutorial on this as well as a question about it but php is not
    allowed in the search box. So i thought i'd just ask what i want to know. I have a form which
    uploads a file, it refreshes the page, uploads the file and then alerts the user to if the file has
    uploaded. To be honest im not sure why i keep getting the error. But here is the code: This is the
    form that is used for the user to select the file &fid= " method="POST"> Choose a file to
    upload: This is the upload code if ($op == "up"....
  9. Proper Way To Grab User Data?
    (1)
    I'm working on a script where there is a custom user profile and I was wondering if there was a
    more efficient way to grab data stored in a database than this method: CODE $sql = "SELECT *
    FROM users WHERE `access_name` = \""  .$active_user. "\""; $row =
    mysql_fetch_array(mysql_query($sql)); //Link the two tables together; grab the most common thing
    that is the *SAME* $user_id = $row ; $sql2 = "SELECT * FROM content WHERE `cid` = \""  .$user_id.
    "\""; $row2 = mysql_fetch_array(mysql_query($sql2)); Then on the pages, I just do a where ever
    something is supp....
  10. Automated File Structure Creation Script
    As Requested By Mark420 (3)
    While chatting with Mark420 today on the shoutbox, he mentioned that he was looking for a script to
    create his entire folder structure with just a click of a button. For example, he wanted the
    following folders created in his root folder by just clicking submit. /images /images/thumbs
    /images/icons /css /javascripts /content /content/articles /content/tutorials Presumably this
    would be used for some type of installation system or other quick server setup situation. Anyhow
    here is what I threw together for him: /* ********************************************....
  11. How To Force A Zip File To Be Downloaded
    (11)
    Hi, i have a problem with a zip file that i want to be force downloaded by any client, i know that
    with the header function it can be achieved but dont know why it doesnt works. I have two files, the
    first one is a simple html file with an a tag and the second is a php file, here is my code: html
    file: CODE Download File Php file: CODE header('Content-Type:
    application/zip'); header('Content-Disposition: attachment; filename="file.zip"');
    readfile('downloads/file.zip'); ?> May be i forgot something, does it is necessary to ....
  12. Backing Up User Forms As Static HTML
    (5)
    System: Activity System for use in Universities Users: Faculty members Scenario: User fills out a
    list of activites they participated in. Example: A faculty member attended a seminar about Object
    Orientated Programming. They record that seminar into their records by filling out a form and
    adding that activity into the database and identifying it with a designed term id. Spring terms are
    different than fall terms etc etc. We want to create html snapshots of these forms that can be
    included by a simple include('oldForm.html') into another form for review. ....
  13. How To Delete File Using PHP Shell Script
    (3)
    i have this problem regarding file access seems that my admin host or the server system itself have
    locked up the acces to create new file, delete a file.. change file permissions and such controls
    to file.. someone told me to use php shell script.. can you help me out here? ******** i just
    need to find out how to use php shell script and add it to my php scripts to delete a file.. thanks....
  14. File Self Secure?
    is it avaible (6)
    I just learn php. We store the pass word of Mysql in a file right. So is there any way to may a pass
    protect that file . i mean they could hack and find out the place of the file (ex like in forum) and
    drop all sercure data /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
    alt="huh.gif" />....
  15. Updating An Rss File Using A Php Form
    (1)
    Hi, I'm currently making a site for my organization but I'm stuck on this one section where
    I would have to make a PHP form in order for other members to post an item into my RSS file. So does
    anyone know a PHP script I can use in order for me and other members to input a new RSS item into my
    news RSS file?....
  16. Xgrid With Php
    Creating a script to post a blender file to Xgrid using PHP (0)
    I am doing pre planning for the blenderxgrid.com script. I was originally going to do this with
    PERL, but elected against it. Eventually I'll be moving the site off astahost and replacing it
    with a website hosted on the same machine as the xgrid controller. I am setting up a test version
    on my latop using OSX's apache server, MySQL, and PHP on a localhost config. Here is my step
    list for the script: ------------------------------------- Form: (within Xoops CMS, so user will
    have to be logged in) Username Password (where they can upload the .blend file....
  17. How To Embed Ram File Produced By Http Header
    (2)
    Dear Friends I want to stream music from my website. The file format is .rm. People say that one
    need a Helix Server or other media server to stream. I have found a solution to this problem as
    well. I read an article about streaming music. It tells that if the size of the media file is small
    and the byte rate of the media file is lower than that of the user internet connections byte rate,
    the file get streamed automatically from HTTP server. In theory, any file is "streamed" by a web
    server that is, sent back to the client in small pieces. What makes media files speci....
  18. User Authentication Session Handling Problems
    Authorization server variables not staying across pages (14)
    This is quite a bit of problem I am facing, and I cannot point exactly where I am going wrong. I
    have been lurking around here at the Asta Host forums with regard to login and user authentication
    scripts and I have got as far as this: - Starting a session - Registering a session variable -
    Using the variable to check if the user is authenticated or not. - Authenticating the user through
    MySQL database - Logging of the user, by setting the session variable to un-authenticated I have
    been able to achive the following things too that I think is not related to this proble....
  19. How To Reset The Server Variable Php_auth_user
    (9)
    Hi, i'm developing a web application which obviously requires a log in/log out script that i
    just implementing but i dont know why the log out script dont work fine. The problem is related
    with the server variable $_SERVER which remains set even when in the log out script i unset it with
    the unset() function. Does someone knows how can i reset or clear the server variable $_SERVER ???
    Best regards, ....
  20. What Database Do You Use With PHP
    Regarding PHP supported database format (5)
    There are different database backends supported by PHP. However, most of us probably use MySQL and
    the books on PHP mostly use MySQL as the backend database. These are the currently supported
    database format: 1. dBase 2. FrontBase (functional since DB 1.7.0) 3. InterBase (functional since
    DB 1.7.0) 4. Informix 5. Mini SQL (functional since DB 1.7.0)6. Microsoft SQL Server (NOT for
    Sybase. Compile PHP --with-mssql) 6. MySQL (for MySQL 7. MySQL (for MySQL >= 4.1) (requires PHP 5)
    (since DB 1.6.3) 8.Oracle 7/8/9 9. ODBC (Open Database Connectivity) 10. PostgreSQL 11. SQL....
  21. PHP Script To Upload A File
    with password-protection. (13)
    Problem: Upload a file to the AstaHost account (that I have been granted here) throught the
    webpage I would like to know, how should I proceed on this particular problem. I know this has
    been done through cPanel, but I want to write a PHP functionality. The cPanel is accessed through
    the 2082 port, and most of the places I access internet from does not give me access through that
    port. I can access http://www.kmaheshbhat.astahost.com/ but not
    http://www.kmaheshbhat.astahost.com/cpanel or http://www.kmaheshbhat.astahost.com:2082/ . I need
    to go to one particu....
  22. Using PHP: Do I Need To Download It?
    (13)
    I am still new at learning coding and whatnot. My question is I want to use PHP code in my web page
    but it doesn't work on my computer. #1. Do I have to download it for me to use it on a hosted
    site. #2. If so, how would I go about downloading it?....
  23. Display Text If Line Not Empty In Config File
    (8)
    I have been working on a new template and I would like it so that if in the global configuration
    file, I have a variable for a global site announcement that would go on every page. The line in the
    global configuration file is this: CODE $announcement = "ANNOUNCEMENT"; In my template file,
    I could easily add CODE but that would leave a blank space and with the announcement style
    (similar to the Invision Power Board error box). Is there some sort of script that could be put in
    the template page so I could have the global config file look something like t....
  24. PHP File Upload Works... But Stupid IE
    (3)
    ok i have used the following code in my upload.php file Code: CODE $uploaddir =
    '../photos/'; $uploadfile = $uploaddir . basename($_FILES ); echo ' '; if
    (move_uploaded_file($_FILES , $uploadfile)) {   echo "File is valid, and was successfully
    uploaded.\n"; } else {   echo "Possible file upload attack!\n"; } using ../photos/ as my
    upload DIR works, as the file does upload, but when i echo $uploadfile on the same page: Code:
    CODE " alt="uploadedfile" /> IE wont show it as it has two fullstops before the photo dir
    in the domain....
  25. Multilingual Site: Send The User To Page Of Choice
    (6)
    If you have one site in diferent laanguages, this simple script can redirect the user to the correct
    page acording to his/her language: CODE // Enslish EUA elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-us"){ header("Location: index_eng.html"); } // Inglês UK elseif ($HTTP_ACCEPT_LANGUAGE ==
    "en-gb"){ header("Location: ingles_enuk.html"); } // Portuguese if ($HTTP_ACCEPT_LANGUAGE ==
    "pt-br"){ header("Location: index_ptbr.html"); } //German elseif ($HTTP_ACCEPT_LANGUAGE ==
    "de-de"){ header("Location: index_ger.html"); } // Swedish elseif ($HTTP_ACCEPT....
  26. Online HTML/PHP Editor: Edit File In Browser!
    (8)
    Im wondering how you can load a file into a text area and edit it. Lets say i have a php file called
    test.php and id like this file to be loaded into a textarea and the user should be able to edit this
    file and store it. Is this posible? Im also wondering how you make it so the html dosnt get
    encoded by the browser, lets say i need to explain on my website how you use html. CODE Just
    testing something, maybe i can get this from the source. ....
  27. Counter With Img In Flat File
    (2)
    this is a counter with images and stor in flat file becouse i can not upload .zip .rar file iwell
    program it on this post at frist you need to 2 files count.php count.txt and you need else make
    folder has name gifs and make 10 pictuer 10 file 0.gif to 9.gif now all ok open the count.php and
    add this code CODE ### IMAGE FORMAT $format = ".gif"; $file = file("count.txt"); $num =
    ($file + 1); exec("echo $num > count.txt"); switch($type) { case "text":  echo $num;  break;
    case "gfx":  $i = 0;  $cntn = strlen($num);  while($i   $tmpnum = subst....
  28. Php Reading And Writing To File
    the code is very esay (4)
    this code to Read from file you can use this code in to make a small data base and it is very to
    use CODE $fp = fopen ("file.txt", "r"); $bytes = 4; $buffer = fread($fp, $bytes); fclose
    ($fp); print $buffer; ------------------- to write to same file CODE $fp = fopen
    ("file.txt", "w+"); fwrite ($fp, "Test"); fclose ($fp); ---------------- thanks and iwait
    the commant....
  29. How Can I Use Php Online On My Pc?
    Do I have to download a program? (4)
    I would like to know how can I set up and use php offline using my computer. Everytime I code to PHP
    I should go online.....
  30. Php Script To Download File From Another Site
    (9)
    hi i need a php or java script code for downloading files from other sites to my site for example:
    http://download.com/file.zip to http://mysite.com/file.zip thanks....

    1. Looking for generating, table, file, csv, format, letting, user, download, file






*SIMILAR VIDEOS*
Searching Video's for generating, table, file, csv, format, letting, user, download, file
Similar
How To Include A File Using Absolute Paths Under A Secure Php Installation - Alternatives to the Include() Function
Myspacetv Download Php Script Help
How To Create/edit/delete Ftp Accounts With Php - Help me to create one php page to create FTP user accounts in Unix Ser
Make A Script Run Even If No User Is Online
Letting Users Add Mysql Data With Php
Automated Product Suggestion Script - Compare user lists and suggest related items based on pattern matching
Extplorer - A PHP -and JavaScript- based File Manager
Php File Upload - About uploading files through php
Proper Way To Grab User Data?
Automated File Structure Creation Script - As Requested By Mark420
How To Force A Zip File To Be Downloaded
Backing Up User Forms As Static HTML
How To Delete File Using PHP Shell Script
File Self Secure? - is it avaible
Updating An Rss File Using A Php Form
Xgrid With Php - Creating a script to post a blender file to Xgrid using PHP
How To Embed Ram File Produced By Http Header
User Authentication Session Handling Problems - Authorization server variables not staying across pages
How To Reset The Server Variable Php_auth_user
What Database Do You Use With PHP - Regarding PHP supported database format
PHP Script To Upload A File - with password-protection.
Using PHP: Do I Need To Download It?
Display Text If Line Not Empty In Config File
PHP File Upload Works... But Stupid IE
Multilingual Site: Send The User To Page Of Choice
Online HTML/PHP Editor: Edit File In Browser!
Counter With Img In Flat File
Php Reading And Writing To File - the code is very esay
How Can I Use Php Online On My Pc? - Do I have to download a program?
Php Script To Download File From Another Site
advertisement




Generating A Table Into A File In CSV Format - and letting user download the file