PHP - Create New Text File Monthly
I got an idea with my homepage in progress. It's a blog and I want to sort my post in a navigation bar. Is it possible to do a script with $date function to create a new file the 1th of every month. Then use file_get_content on the current month.
To clarify in this stage I haven't started connecting my database.
Edited by DexterTheCat, 05 June 2014 - 11:16 AM. Similar TutorialsI would like some tips on how to create a monthly archive for my weblog. I am not using MySQL or any databases. Everything is saved on file. any tips or tutorials? Thanks Hello Friends... I am creating a HTML webpage and connecting with MYSQL. If the client will check the conditions, it will pass it to PHP and get values from MYSQL and print it in the webpage as a HTML table format. Now i want to create a SAVE button and save the HTML TAble values as TXT tab demilited file. I tried of creating a TXT file by using fopen() and write the values by using fwrite() function. But it is working only in the putty. While running the program from the browser, its not working. Will somebody help me to solve this prob? I also was searched for creating a TXT file from HTML table. But i wouldnt get any codes reg this.... Thanks Rose I have a Php application that already has 2 buttons with input on the index page that perform some functions and output to different Php pages. Works good. How do I add a button with no input that would just perform a function and then just display a popup window showing the contents of a text file? I want to add several of these buttons for different functions and just display the contents of the resulting text files in popup windows. Any help would be greatly appreciated. Thanks in advance. Hello, I have created database "acc" which stores my income and expenses in a table called "inex" . I want to see the monthly total expense and incomes in view.php i tried to do it but messed up with the code as i am a newbie. does anyone know a sample code for this kinda purpose or help me with the query? thanks alot Hi, i have created a mysql table for account info which stores basic expenses and income I have also account.php page that shows the all transactions 10 transaction (row) per page. there is no problem with that but I like it to show the transactions(entries) per month base. I mean when i open this page i want it to show this month's entries. and when i click previous button i like to see last month's entries. any help will be appreciated. thanks in advance. regards. Okay guys, I figured out how to calculate monthly subscriptions into days, but I am stuck on calculating multiple monthly subscriptions.. for example Heres my mysql table: How would I calculate this: Subscription Start: February 21, 2011, 12:00 am Subscription End: April 22, 2011, 12:00 am Subscription Left: 60 days My trouble is that when the user buys another month, it calculates the end time based on the new "Subscription Start Date". Or vice versa. Any ideas guys? Thanks. Hi all, I'm trying to make a webpage that allows the user to enter new sales figures for a certain product in a chosen month of a chosen year. I thought my code was correct but it doesn't really do anything. It just displays the table but it's not updated. Can anybody spot an error? Code: [Select] $describeQuery = "SELECT p.ID, p.NAME, dt.[Year], dt.[Month], dt.SalesVolume from Products p join (select ProductCode, sum(SalesVolume) as SalesVolume, [Month], [Year] from MonthlySales where [Year] = '$desiredYear' AND [Month] = '$desiredMonth' group by ProductCode, [Year], [Month])dt on dt.ProductCode = p.ID"; $editQuery = "UPDATE MonthlySales SET SalesVolume = '$newSales' WHERE Month ='$desiredMonth' AND Name = '$desiredProduct' AND Year = '$desiredYear'"; $results = sqlsrv_query($conn, $describeQuery); $resultsx = sqlsrv_query($conn, $editQuery); echo '<table border="1" BORDERCOLOR=Black>'; echo '<tr><th bgcolor = "LightBlue">Name</th><th bgcolor = "LightBlue" >ID</th> <th bgcolor = "LightBlue" >Sales</th><th bgcolor = "LightBlue" >Month</th> <th bgcolor = "LightBlue" >Year</th> </tr>'; while($row = sqlsrv_fetch_array($results, SQLSRV_FETCH_ASSOC)) { echo '<tr>'; echo '<td >' .$row['NAME'].'</td>'; echo '<td>' .$row['ID'].'</td>'; echo '<td>' .$row['SalesVolume'].'</td>'; echo '<td>' .$row['Month'].'</td>'; echo '<td>' .$row['Year'].'</td>'; echo '</tr>'; } echo '</table>'; while($row = sqlsrv_fetch_array($resultsx, SQLSRV_FETCH_ASSOC)) { } sqlsrv_close($conn); I'm using a php $_POST variable as the name of a file that I want to create. fopen() , according to my understanding open the file if it exists or creates it if it doesn't. $Ref = $_POST['Ref']; I using each reference element of $Ref as the name of a file in a certain directory. So if $Ref[$i] exists as a file name in a certain directory, append to the file, if it doesn't create the file in that directory and write to it. Do I use the file path of the file within fopen()? fopen(./References/$Ref,a) or fopen(./References/$Ref,w)? I am trying create my xml file in this format: Code: [Select] <?xml version="1.0" encoding="UTF-8" ?> - <playlist id="Adobe"> <vid desc="5 minute cardio warm-up" contenu="side jumps, arm curls ..." src="videos/set2_first_5min.flv" thumb="thumbs/set2_first.png" /> <vid desc="5 minutes of no rest workout moves" contenu="Football drills, front kicks ..." src="videos/set2_second_5min.flv" thumb="thumbs/set2_second.png" /> <vid desc="last 5 minutes of Set 1" contenu="MC Hammer ..." src="videos/set2_third_5min.flv" thumb="thumbs/set2_third.png" /> <vid desc="5 minute cardio warm-up" contenu="jumping jacks, presses and squats" src="videos/Set1_first.flv" thumb="thumbs/set1_first.jpg" /> <vid desc="5 minutes of no rest workout moves" contenu="shin kicks ..." src="videos/Set1_mid.flv" thumb="thumbs/set1_mid.jpg" /> <vid desc="last 5 minutes of Set 1" contenu="MC Hammer ..." src="videos/Set1_last.flv" thumb="thumbs/set1_last.jpg" /> </playlist>[/color] I'm not having trouble getting and looping through the data from mySQL. I'm getting confused with what's a child element, attribute node, and attribute value. Can someone who has worked with the DOMDocument steer me in the right direction? sample code is the best request Thanks! Hi all I'm trying to create an XML file to be used within Excel. The data is drawn dynamically from my database depending on the information supplied by the user. However when I run it, I get a complain from Excel about some missing whitespace. any ideas? Code: [Select] <?php $output='<?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office"> <Author>Europcar</Author> <LastAuthor>Europcar</LastAuthor> <Created>2011-10-28T10:48:37Z</Created> <Company>Europcar</Company> <Version>11.9999</Version> </DocumentProperties> <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel"> <WindowHeight>11760</WindowHeight> <WindowWidth>15195</WindowWidth> <WindowTopX>480</WindowTopX> <WindowTopY>75</WindowTopY> <ProtectStructure>False</ProtectStructure> <ProtectWindows>False</ProtectWindows> </ExcelWorkbook> <Styles> <Style ss:ID="Default" ss:Name="Normal"> <Alignment ss:Vertical="Bottom"/> <Borders/> <Font/> <Interior/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Sheet1"> <Table ss:ExpandedColumnCount="'.$columns.'" ss:ExpandedRowCount="'.($count+5).'" x:FullColumns="1"x:FullRows="1">'; //$output.='<Column ss:AutoFitWidth="0" ss:Width="50"/>/n'; $output.='<Row>'; foreach ($titles as $value){ if(is_numeric(substr($value,0,1))){ $value=substr($value,1); } $output.='<Cell><Data ss:Type="String">'.$value.'</Data></Cell>'."LF"; } /*$output.='</Row>'; foreach ($dataOut as $value){ $output.='<Row>'; foreach($value as $values){ if(strlen($values)<1){ $values=" "; } $output.= '<Cell><Data ss:Type="String">'.$values.'</Data></Cell>'; } $output.='</Row>'; }*/ $output.=' </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <Selected/> <Panes> <Pane> <Number>3</Number> <ActiveRow>'.($count+5).'</ActiveRow> <ActiveCol>'.$columns.'</ActiveCol> </Pane> </Panes> <ProtectObjects>False</ProtectObjects> <ProtectScenarios>False</ProtectScenarios> </WorksheetOptions> </Worksheet> </Workbook>'; Hey, i'd like to extract filenames from my database and present them as a downloadable zip-file to my users. I found a usefull function on http://davidwalsh.name/create-zip-php and thought i could work that out to my needs, but on this function itself (before using it), i get an error.. on the following line: if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { i get: Parse error: syntax error, unexpected ')', expecting '(' i dont get it, dont think there is actually an error in the function.. does it mean that the php installed on the server i use, cant handle this function or anything? my phpinfo: http://dwarsfluit.davidvandiepen.nl/test.php the function is: Code: [Select] <?php /* creates a compressed zip file */ function create_zip($files = array(),$destination = '',$overwrite = false) { //if the zip file already exists and overwrite is false, return false if(file_exists($destination) && !$overwrite) { return false; } //vars $valid_files = array(); //if files were passed in... if(is_array($files)) { //cycle through each file foreach($files as $file) { //make sure the file exists if(file_exists($file)) { $valid_files[] = $file; } } } //if we have good files... if(count($valid_files)) { //create the archive $zip = new ZipArchive(); if($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== true) { return false; } //add the files foreach($valid_files as $file) { $zip->addFile($file,$file); } //debug //echo 'The zip archive contains ',$zip->numFiles,' files with a status of ',$zip->status; //close the zip -- done! $zip->close(); //check to make sure the file exists return file_exists($destination); } else { return false; } }?> thanks for helping! Hello, please let me know how to write xml file, i read somewhere we can use psql.....anyone knows please help! Thanks i am working on a report tool was developed in linux. Currently i am developing same thing in windows. So i need to have a knowledge in creating batchfiles in php with windows Os. Suggestions/Help needed urgently This should create a gb.txt in the local folder but its not creating it? What is wrong with it pls help <html> <head> <title>Guestbook</title> </head> <body> <?php extract($_REQUEST); ?> <?php if(isset($submit)) { saveGuestbook($name, $email, $comments); showGuestbook(); } elseif($check){ showGuestbook(); }else{ callForm(); } ?> <?php function showGuestbook() { echo "<body bgcolor='#DAE5CD'>"; echo "<font color='#cc3333' size='+2'><b>Thank You!</b></font> <br><br>"; $data = file("gb.txt"); foreach ($data as $line) { $line = rtrim($line); echo "<hr>"; list($name, $email, $comments) = split ("\t", $line); echo "Name: $name<br>"; echo "Email: $email<br>"; echo "Comments: $comments<br>"; } echo "<hr><p><a href = 'guestbook.php'>Click here </a> to go back </p>"; } function saveGuestbook($nam, $mal, $com) { $fh = fopen("gb.txt"); $nameData = $nam. "\t"; fputs($fh, $nameData); $mailData = $mal. "\t"; fputs($fh, $mailData); $commnetsData = $com. "\n"; fputs($fh, $commnetsData); fclose($fh); } function callForm() { print <<<DONE <font color="#CC0000" size="+2">Please sign our guestbook</font> <br > <br > <form name="Guestbook" method="post"> <table bgcolor="#DAE5CD"> <tr> <td valign="top">Name: </td> <td><input type="text" name="name" size="25" value="Your Name"></td> </tr> <tr> <td valign="top">E-mail:</td> <td><input type="text" name="email" size="25" value="example@mail.com"></td> </tr> <tr> <td valign="top">Comments:</td> <td><textarea rows="5" cols="30" name="comments">Comments</textarea></td> </tr> <tr> <td></td> <td align="right"><input type="submit" name="submit" value="submit"> <input type="reset" value="Clear"> </td> </tr> </table> </form> <p>Want to check out our <a href="guestbook.php?check=check"> guestbook?</a></p> DONE; } ?> </body> </html> guys i want to to create a html invoice to pdf file how can i do that ...by using which library...can any one help me out? Hey! I am making a comment system for my blog I'm making. The way I want it, is that when a comment is posted, it grabs the id of the post it's referring to, then creates a file called comment(POST ID HERE).txt.. I have that down, however I cannot for the life of me figure out how I can make it an increment, so it can make no more than 500, but everytime a comment is posted it will keep making the files go up like: comment1.txt comment2.txt comment3.txt Etc... Thanks very much, happy holidays! Hey there, Thanks for taking the time to read my thread, well basically I'm in a bit of a dilemma. I've got a string in PHP containing the contents of a file I would like to be created and I have a method of sending the command to the remote server like so: $Connection->exec('ps aux'); Now my issue is I am unaware of any file editors via command like that don't have some sort of user prompt I've scoured Google for hours searching for the best possible method for this but all the file editors aren't simply processed by one line commands and edited in that same command e.g Create File -> Write File -> Close File Is there no possible means of doing that via one line command?. Here is my string I wish to be written to the file. $RestartFile = "#!/bin/bash export SERVER_PATH=/home/client".$Server['server_owner']."/".$Server['server_id']." cd $SERVER_PATH while [ true ]; do ./server".$Server['server_id']." & done"); Thank you for your time. Hi All, I don't really need help with the code, I just need to know the process... This will take place in a simple form. The user enters the payment information and checks off 'Send Receipt' option. From there, the payment data is stored in the DB. Then, I need to have a PDF generated of the receipt and finally email the tenant with confirmation and the PDF that was created. Once the data is inserted, I can use fPDF to merge the data to the PDF document I created. That part I don't understand is how to automatically save that file and attach it to an email. Ideas / suggestions? Hi, Just looking how to create a link to download a file located on the server, it will be files like .doc etc. Cant seem to find anything on the net so i think i need php but may be html. Can anyone point me in the right direction? Thanks p.s. it will be used for more than one file so im looking for a small ish amount of code. I want to save an image with a unique name that is created from a hash function. How can I cretae the path with the variable... Code: [Select] $hash=$_GET['hash']; $path ="/Applications/MAMP/htdocs/test_upload/images/imagename2.png"; //becomes $path ="/Applications/MAMP/htdocs/test_upload/images/'.$hash.'.png";? |