PHP - Need Help To Print Large Html Table
We have booking data in spreadsheet looks like table in below, and each booking is for a full week.
| wk1 | wk2 | wk3 | wk4 | wk5 |..........| wk52 | ================================== E1 | resv | |resv | |resv | |resv E2 | | resv |resv |resv | E3 | resv | resv |............................................... E4 | resv | E5 | ... | resv | resv|.................................... ... | E50|resv | resv | | resv It looks great excel but required one person to manage all bookings. So we moved to web interface and allow users to make their own bookings. Now, data moved to sql database with fields (id, wk#, room, other....), and records like below. 01 wk1 E1 02 wk1 E3 03 wk1 E4 ..... etc.... nn wk2 E2 nn wk2 E3 ... and more Now, I need a method in PHP to print above data in HTML table that looks like excel table in above. It doesn't have to print 52 wks in one page, but at least something like 4 wks view and next page to show the next 4 wks. At start it will print the first 4 wks from the current week (wk 11), and next page will print wk12 to wk15, etc. | wk1 | wk2 | wk3 | wk4 =================== E1 | resv | |resv | E2 | | resv |resv |resv E3 | resv | resv |............... E4 | resv | E5 | more rows...... Can someone here give me a direction how to code this in PHP? Thank you very much! bobo Similar TutorialsHey guys, I'm a total newbie here, and just about as a new to php. My issue: I have a very large .html file that contain multiple articles (I actually have a few of these, but we'll start with one for practicality). The article titles are all wrapped in <h2> tags, there are 10 articles in one file. The articles are very simple, just a title wrapped with <h2> and then a few paragraphs wrapped in <p> tags. What I want to know how to do: I want to know if there's a way to open that file, and have each article saved as it's own .html or .txt document (the title & following paragraphs of each article). Ultimately taking my 1 large file, and creating the subsequent 10 smaller files from the articles inside of it. I am having trouble explaining this in text so I'll try to illustrate: I have "Articles.html" - which contains (article1,article2,article3.. ..article10) I want to split "Articles.html" and create "Article1.html", "Article2.html", "Article3.html", etc. Is that possible? Or am I looking at something far more complex than I can imagine at this point - perhaps something I'd be better off doing by hand? Ultimately I intend to stick all these articles into a database, but that's the 2nd part of what I want to do (and I think will be the easier of the tasks). Let me know if you need any additional information in the event my description above is unclear... I simply am having issues figuring out how to separate out the text into individual articles. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=307147.0 i need help here..i want to echo a lage code of html but it is giving me problems..i know it will hv to do with the syntax but am confused on how to go about it..below is the php code and the html codes Code: [Select] <?php include"header.php"; session_start(); if(isset($_POST['submit'])) { $log=mysql_real_escape_string($_POST['mail1']); $pas=($_POST['pass1']); if($log=='' || $pas=='') { echo "Please supply your Username(your email address) and your password"; } else { $sel="SELECT user_name,userID FROM user WHERE (user_email='$log') AND (user_password='$pas')"; $ok=mysql_query($sel) or die(mysql_error()); if(mysql_num_rows($ok)==0)echo"Wroung Username or Password used,Please try again"; else { while($row=mysql_fetch_array($ok)) { $_SESSION['userID']=$row['userID']; $_SESSION['user_name']=$row['user_name']; $_SESSION['user_date']=$row['user_date']; echo $_SESSION['user_date']=$row['user_date']; echo"this is where i want to put the html codes so that the user_name appears on the page".$_SESSION['user_name']; } } } } mysql_close(); ?>this is the html codes Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta name="Description" content="Information architecture, Web Design, Web Standards." /> <meta name="Keywords" content="your, keywords" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="Distribution" content="Global" /> <meta name="Author" content="Erwin Aligam - ealigam@gmail.com" /> <meta name="Robots" content="index,follow" /> <link rel="stylesheet" href="images/PixelGreen.css" type="text/css" /> <title>Planetafric</title> </head> <body> <!-- wrap starts here --> <div id="wrap"> <div id="header"><div id="header-content"> <h1 id="logo"><a href="index.html" title="">speak<span class="gray">out</span></a></h1> <h2 id="slogan">The Revolution is now...</h2> <!-- Menu Tabs --> <ul> <li><a href="index.html" id="current">Home</a></li> <li><a href="index.html">News</a></li> <li><a href="index.html">Downloads</a></li> <li><a href="index.html">Support</a></li> <li><a href="index.html">About</a><li> </ul> </div></div> <div class="headerphoto"></div> <!-- content-wrap starts here --> <div id="content-wrap"><div id="content"> <div id="sidebar" > <div class="sidebox"> <h1>About this Website</h1> <p>Due to the injustice we face conitnualy in this nation WE (KTECHGROUP) have decided to stamp our feet against all this ills in our country..THE TIME IS NOW ..Stand against non avalabitlty of social amenities, stand against unemployment and stand against corruption.<img src="speakout_1.png"/></p> </div> <div class="sidebox"> <h1 class="clear">Sidebar Menu</h1> <ul class="sidemenu"> <li><a href="index.html" class="top">Home</a></li> <li><a href="#TemplateInfo">Template Info</a></li> <li><a href="#SampleTags">Sample Tags</a></li> <li><a href="http://www.styleshout.com/">More Templates...</a></li> <li><a href="http://www.4templates.com/?aff=ealigam">Premium Templates</a></li> </ul> </div> <div class="sidebox"> <h1>Sponsors</h1> <ul class="sidemenu"> <li><img src="watch.jpg"/></br><h3>Longinnes wrist watch forsale at reduced price</h3></li> <li><img src="htc.jpg"/><label>4templates</label</li> <li><a href="http://store.templatemonster.com/?aff=ealigam">TemplateMonster</a></li> <li><a href="http://www.fotolia.com/partner/114283">Fotolia.com</a></li> <li><a href="http://www.text-link-ads.com/?ref=40025">Text Link Ads</a></li> </ul> </div> <div class="sidebox"> <h1>Wise Words</h1> <p>"No man can live happily who regards himself alone; who turns everything to his own advantage. You must live for others if you wish to live for yourself."</p> <p class="align-right">- Seneca</p> </div> <div class="sidebox"> <h1>Support Speakout</h1> <p>If you are interested in supporting this work and would like to contribute, you are welcome to make a small donation through the <a href="http://www.styleshout.com/">donate link</a> on this website - it will be a great help and will surely be appreciated.</p> </div> <div class="sidebox"> <h1>Search Box</h1> <form action="#" class="searchform"> <p> <input name="search_query" class="textbox" type="text" /> <input name="search" class="button" value="Search" type="submit" /> </p> </form> </div> </div> <div id="main"> <div class="post"> <a name="TemplateInfo"></a> <h1> </h1> <p>Posted by <a href="index.html">Adetoye Oni</a></p> <p><strong>A weeping Eye</strong> is a free, W3C-compliant, CSS-based website template by <strong><a href="http://www.styleshout.com/">styleshout.com</a></strong>.<p align="left"><img src="soldier_crying.jpg"/></p align> This work is distributed under thel;kmbkl;;lsjljhl;hjklghl;kk;gjhflk;jfgkl;jflhjflkhlkkjgfklk Creative Commons Attribution 2.5 License</a>, which means that you are free to use and modify it for any purpose. All I ask is that you include a link back tohjsklvjksjkskjvskdv dhlkdhlshdlkjhdslkjhkljsdhjsdhjlghdsjhjkdshgjkdhjkshdjkhdsjkhdkjsjgdgl sddjgkldsjlkgdlkshgldhsgldhlghdlshgdlhgldhlkhdlkdkhdlkgdgd djkdjklgdjklgjdslkjdlksjkldsjkldsjlkdsjklgjsldkjgkldsgdsgjdklsgjsljgl\ksdjgjldkgj;ldsk\jglkdsg <a href="http://www.styleshout.com/">my website</a> in your credits.</p> <p>For more free designs, you can visit <a href="http://www.styleshout.com/">my website</a> to see my other works.</p> <p>Good luck and I hope you find my free templates useful!</p> <p class="post-footer align-right"> <a href="index.html" class="readmore">Read more</a> <a href="index.html" class="comments"><?php if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo"Comments:".$_SESSION['views']; ?></a> <span class="date">Nov 11, 2006</span> </p> </div> <h3>Comments:</h3> <table> <tr class="row-a"> <td class="first"><?php include"header.php"; $sql="SELECT *FROM post "; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['post_date']}"."</br>"; } ?></td> <td><?php include"header.php"; $sql="SELECT *FROM post "; $result=mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)) { echo"{$row['post_content']}"."</br>"; } ?></td> </tr> </table> <h3>Post your comments here</h3> <form action='reply.php'method='post'> <textarea name="comment" id="content" style="width:400px;height:50px;background-color:#D0F18F;color:#000000;font:15px/20px cursive;scrollbar-base-color:#638E0D;"></textarea> <br /> <input class="button" type="submit"name="submit"value="submit" /> </p> </form> <br /> </div> <!-- content-wrap ends here --> </div></div> <!-- footer starts here --> <div id="footer"><div id="footer-content"> <div class="col float-left"> <h1>Site Partners</h1> <ul> <li><a href="http://www.dreamhost.com/r.cgi?287326"><strong>Dreamhost</strong> - Affordable & Reliable Webhosting</a></li> <li><a href="http://www.4templates.com/?aff=ealigam"><strong>4templates</strong> - Low Cost Hi-Quality Templates</a></li> <li><a href="http://store.templatemonster.com/?aff=ealigam"><strong>TemplateMonster</strong> - Best templates on the net!</a></li> <li><a href="http://www.fotolia.com/partner/114283"><strong>Fotolia</strong> - Free stock images or from $1</a></li> <li><a href="http://www.text-link-ads.com/?ref=40025"><strong>Text Link Ads</strong> - Easiest. Money. Ever.</a></li> </ul> </div> <div class="col float-left"> <h1>Links</h1> <ul> <li><a href="http://www.openwebdesign.org/">openwebdesign.org</a></li> <li><a href="http://www.opendesigns.org/">Opendesigns.org</a></li> <li><a href="http://www.pdphoto.org/">PDPhoto.org</a></li> <li><a href="http://www.alistapart.com">Alistapart</a></li> <li><a href="http://www.cssremix.com">CSS Remix</a></li> </ul> </div> <div crrlass="col2 float-right"> <p> © copyright 2006 <strong>Ktech group</strong><br /> Programme by: <a href="index.html"><strong>Adeleye Caleb</strong></a> Valid <a href="http://jigsaw.w3.org/css-validator/check/referer"><strong>CSS</strong></a> | <a href="http://validator.w3.org/check/referer"><strong>XHTML</strong></a> </p> <ul> <li><a href="index.html"><strong>Home</strong></a></li> <li><a href="index.html"><strong>Sitemap</strong></a></li> <li><a href="index.html"><strong>RSS Feed</strong></a></li> </ul> </div> </div></div> <!-- footer ends here --> <!-- wrap ends here --> </div> </body> </html> Thanks in advance and this is the html while($row = mysql_fetch_row($query)) { echo "<tr>"; echo '<td>' . $row[0] . '</td>'; echo '<td>' . $row[1] . '</td>'; echo '<td>' . $row[2] . '</td>'; echo '<td>' . $row[3] . '</td>'; echo '<td>' . $row[4] . '</td>'; echo "</tr>\n"; } Currently I have this code. I would like to make it print certain text, let's say... 'car', if the value of table's column 'automobiles' is equal to 0. Otherwise - print the real value. I've tried if statement and $one = $two... But that apparently didn't worked. Thanks. [ Newbie Alert ] Hi i have an array of 39 arrays. Only 5 are shown below so that you have an idea before i ask my question. <? array(39) { [0]=> array(3) { [0]=> string(18) "unit name 1" [1]=> string(9) "category name 1" [2]=> string(20) "Course 1" } [1]=> array(3) { [0]=> string(54) "unit name 2" [1]=> string(15) "category name 2" [2]=> string(20) "Course 1" } [2]=> array(3) { [0]=> string(29) "unit name 3" [1]=> string(15) "category name 2" [2]=> string(20) "Course 1" } [3]=> array(3) { [0]=> string(64) "unit name 4" [1]=> string(30) "category name 3" [2]=> string(20) "Course 2" } [4]=> array(3) { [0]=> string(57) "unit name 5" [1]=> string(24) "category name 1" [2]=> string(20) "Course 1" } [5]=> array(3) { [0]=> string(50) "unit name 6" [1]=> string(24) "category name 4" [2]=> string(20) "Course 2" } } i want a php solution to print category names in table headers , unit names in table rows and course name(s) in table caption.I have tried foreach loop but how to remove duplicate entries as you can see category name 1 and 2 will become two separate headers instead of one and same is the case with Course 1 and 2. i have googled but could'nt find any solution. i don't want to remove duplicate entries , all i want to display them once in a table as described above. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=355885.0 What I want to do is what is in the shown in the table. I want to only get the Math subject and order the units from unit 1 (UI) to the last available unit in the database; after this, under each unit, to show the homework related to each unit. I have tried to save it into an array with mysql_fetch_array but it stores the row that involves one unit. I want all the units and only the units with their homework under them.
My database is attached to this post in a txt file.
hope someone can help.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Documento sin título</title> </head> <body> <form action="" method="post" name="form1" id="form1"> <table width="200" border="1"> <tr> <td>Subject:</td> <td>Math</td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td>UI</td> <td>UI</td> <td>UII</td> <td>UIII</td> <td>UII</td> <td>...</td> </tr> <tr> <td>Home work</td> <td>Math work1</td> <td>Math work2</td> <td>Math work3</td> <td>Math work4</td> <td>Math work5</td> <td>...</td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> </body> </html> Ok so here's what I'm trying to do and what I'm having to do since I can not figure out how to script this.
I create my GUI for scripting in HTML. When I script I create a full HTML page for my input forms, one full HTML page for the error code and lastly one HTML page for the receipt when the script runs correct. I then create my php scripting (basic template where I can cut and paste my HTML for the GUI output once it has been encapsulated in FULL be the php print function after having the quotation marks escaped and replaced by a backslash follow by a quotation mark).
Currently and over the past Decade. I have done this encapsulation the Hard way. Meaning I build my HTML file in FrontPage. I save the HTML file and then I open it in Microsoft Notepad. First thing I do is use the replace All function from the edit menu to Find every instance of " and replace them all with \" then I manually goto the first line of code and place a Tad then type print " I then hold control and shift to copy the ( tab print ") and begin to paste manually using Ctrl V and then I hit the down arrow on my keyboard quickly followed by the Home button to drop my cursor down a line and input the beginning of my PHP print function encapsulation one frigging line at a time. Once I've reach the very bottom, I go up the back right hand side of the HTML document with my ending quotation followed by semi colon manually with Ctrl V and hitting up arrow followed by end button.
This process of encapsulation the hard way with note pad takes up 90% of my dev time when programming. It makes stuff easy to read in my code and is perfect for outputting. What I would like to do is find a way to create a php script with a file upload form field that would take the input of any and all html files and parse the full document automating the exact process that I run on all of my HTML GUI files so that I can turn the encapsulation work into nothing and focus on the actual scripting.
You wouldn't believe how many hours of Ctrl V and up n down end and home I have pressed. Spent 8 hours last night alone. When form fields have multiple drop down selectors for country code ect. the HTML files to encapsulate manually become Ridiculously long.
I have never seen or heard of anyone doing exactly what I've explained here as I know the print function used like this is not normal. Every HTML file or snippet in any of my scripting is always encapsulated in the print function to output. And I have no intentions on changing my style. I would like to automate my process. And if it is too complex for me to build it in a decent amount of time I am willing to pay good money to get this finished for me ASAP.
Please message me back ASAP as I'm working on a personal project that has over 2,000 HTML files for me to encapsulate a the minimum.
~PJ
I am trying to print the list of a table which I requested with "SELECT DISTINCT" as below Code: [Select] $db_connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $sql_get = "SELECT DISTINCT category FROM con"; $sql_run = mysqli_query($db_connect, $sql_get) or mysqli_error($db_connect); $sql_assoc = mysqli_fetch_assoc($sql_run); What is now needed to print the list of the table data by this conditions? I tried the while loop, but I seem to approach wrong, and get endless loops or errors. Hello, I need some help. Say that I have a list in my MySQL database that contains elements "A", "S", "C", "D" etc... Now, I want to generate an html table where these elements should be distributed in a random and unique way while leaving some entries of the table empty, see the picture below. But, I have no clue how to do this... Any hints? Thanks in advance, Vero I know I'm doing it something right, but can someone tell me why only one table is showing up? Can you help me fix the issue? Heres my code: function showcoords() { echo"J3st3r's CoordVision"; $result=dbquery("SELECT alliance, region, coordx, coordy FROM ".DB_COORDFUSION.""); dbarray($result); $fields_num = mysql_num_fields($result); echo "<table border='1'>"; // printing table headers echo "<td>Alliance</td>"; echo "<td>Region</td>"; echo "<td>Coord</td>"; // printing table rows while($row = mysql_fetch_array($result)) { // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach($row AS $Cell) echo "<tr>"; echo "<td>".$row['alliance']."</td>\n"; echo "<td>".$row['region']."</td>\n"; echo "<td>".$row['coordx'].",".$row['coordy']."</td>\n"; echo "</tr>\n"; } echo "</table>"; mysql_free_result($result); } I have 2 rows inserted into my coords table. Just frustrated and ignorant to php. Hi all So... I am creating an import script for putting contacts into a database. The script we had worked ok for 500kb / 20k row CSV files, but anything much bigger than that and it started to run into the max execution limit. Rather than alter this I wish to create something that will run in the background and work as efficiently as possible. So basically the CSV file is uploaded, then you choose if the duplicates should be ignored / overwritten, and you match up the fields in the CSV (by the first line being a field title row), to the fields in the database. The field for the email address is singled out as this is to be checked for duplicates that already exist in the system. It then saves these values, along with the filename, and puts it all into an import queue table, which is processed by a CRON job. Each batch of the CRON job will look in the queue, find the first import that is incomplete, then start work on that file from where it left off last. When the batch is complete it will update the row to give a pointer in the file for the next batch, and update how many contacts were imported / how many duplicates there were So far so good, but when checking for duplicity it is massively slowing down the script. I can run 1000 lines of the file in 0.04 seconds without checking, but with checking that increases to 14-15 seconds, and gets longer the more contacts are in the db. For every line it tries to import its doing a SELECT query on the contact table, and although I am not doing SELECT * its still adding up to a lot of DB activity. One thought was to load every email address in the contacts table into an array before hand, but this table could be massive so thats likely to be just as inefficient. Any ideas on optimising this process? Hi guys, I am currently receiving a large text file ( > 500mb), once per week which I have been manually splitting then processing to obtain the required CSV files. However, this is taking in the region of 2 to 3 hours. Very soon, these files will be sent daily and I really dont have the time to split and process this everyday I have been playing for a while to try and parse everything properly/automatically with fopen, feof and fgets ( and other 'f' options), but the script never seems to read the file all the way to the end - I assume this is due to memory usage. The data received in the file follows a strict pattern throughout the file which is: Code: [Select] BSNY990141112271112270100000 POO2C35 122354000 DMUS 075 O BX NTY LOLANCSTR 1132 11322 TB LIMORCMSJ 1135 00000000 LICRNFNJN 1140 00000000 H LICRNF 1141H1142H 11421142 T LISDAL 1147H1148H 11481148 T LIARNSIDE 1152H1153 11531153 T LIGOVS 1158 1159 11581159 T LIKTBK 1202 1202H 12021202 T LICARK 1206 1207 12061207 T LIULVRSTN 1214H1215H 12151215 T LIDALTON 1223 1223H 12231223 T LIDALTONJ 1225 00000000 LIROOSE 1229 1229H 12291229 T 2 LTBAROW 1237 12391 TF That is just one record of informaton (1 of around 140,000 records), each record has no fixed amount of lines but each line in each record is fixed to 80 characters and all lines in each record need to have the same unique 'id', at present, Im using an md5 hash of microtime. The first line of every record starts with 'BS' and the last line of each record starts with 'LT' terminating with 'TF'. All the other stuff between also follows a certain pattern of which I can break down effectively. The record above show one train service schedule, hence why each line in each record needs the same unique id. Anyone got any ideas on how I could process such a file effectively?? Many thanks Dave Hello all is there any way to save a dynamic table to xls file as is? i mean the colors and all the style i use for the table. is there any function that do this? i found PHPExcel.... but i dont have the time or the power to start learn all the functions.... any simple class that do so? Hi, Have taken a look around and cannot find an answer to this one. I have the following page producing an HTML table http://www.weatherweb.net/weathertest.php I'd like the table to export (automatically) as a csv file. Is this possible, and if so how? With thanks, Simon Hello All This was an online test, which I didn't do very well with, and am looking for guidance of where I went wrong. The idea is you'd have a matrix $A with values -1, 0, 1 in each position, in rows M and column N where M,N can be up to 1000. The code is evaluated $k times where $k can be up to 1000 as well. Starting at $A[0][0], evaluate the matrix where -1 means you go down a row and +1 means you go right one column. A 0 value means you continue along your previous direction. After exiting a position, that positions value is multiplied by -1: 1 = (-1); (-1) = 1; 0 = 0 Once you exit the matrix either on the right or below, you stop and start over The goal of the code is to return how many times you exited the bottom right corner, ending up below (not to the right) the matrix; When your spot is [M], [N+1] Here is the code I wrote: Code: [Select] function eval_matrix( $A, $k ) { $x = 0; $y = 0; // dir is x or y for up/down // $dir = "y"; $ball_count = 0; // Get columns // $maxX = count($A); // Get rows // $maxY = count($A[0]); // for $k times for($i=0; $i<$k; $i++) { // while we're within the matrix boundaries while($x < $maxX && $y < $maxY) { // get the value of our current position $mode = $A[$x][$y]; // evaluate the value 0,1,-1 switch($mode) { case 0: if($dir =="y") { $y++; } else { $x++; } break; case -1: // Change position value $A[$x][$y] = 1; $y++; $dir = "y"; break; case 1: // Change position value $A[$x][$y] = -1 $x++; $dir = "x"; break; } } if($x == $maxX-1 && $y == $maxY) { $ball_count++; } $x = 0; $y = 0; $dir = "y"; } return $ball_count; } It may be fairly ugly, but I'm looking for help with how to properly code this type of solution. Any pointers, resources, suggestions are greatly appreciated! I have an application which takes some time and would like to take steps to improve execution speed. Sample data is provided as JSON and is as follows where the values array has few columns and many rows. My desired outcome is three PHP objects for mean_P51, mean_P55, and max_P56 which all have a reference to the time array as well as their own values array. { "name": "L2", "columns": ["time", "mean_P51", "mean_P55", "max_P56"], "values": [ ["2020-06-13T14:02:02Z", 4.3527550826446255, 5.668302919254657, 0.6175362252066116], ["2020-06-13T14:02:12Z", 4.472219604166665, 5.493282520833331, 0.6095558604166668], ["2020-06-23T14:02:22Z", 4.332343173277662, 5.477678517745302, 0.6014520167014615], ... ["2020-06-23T14:02:22Z", 4.272219604166665, 5.468302919254657, 0.6195558604166668] ] } Originally, I thought that it would be more efficient to iterate over the big values array once and on each iteration process each column (I envision myself walking one mile and snapping my fingers three times each foot, or walking three miles and snapping my fingers once every foot). What I witness, however, is it is faster to iterate over the big values array multiple times to generate each object, and I've done a few simple tests comparing iterating big loops within little loops to little loops within big loops, and get similar results. I guess this makes sense I am not really stopping when I snap my fingers and if I did walking three miles would likely be quicker. Is this expected behavior? If there is too much data, I've needed to use a JSON stream parser and either a generator or iterator. I haven't tested it yet, but expect a generator would be more efficient than an iterator and using PHP's built-in json_decode() and an array would be more efficient than either a generator or iterator. Think I need to test this hypothesis or is it likely correct? Any other general strategies one should take when working with large datasets? Thanks Hi All, Having issues uploading files larger than 1mb. This is what I have currently as default when I ran phpinfo() (working locally on my machine)... upload_max_filesize: 432M post_max_size: 432M memory_limit: 8M max_input_time: 60 max_execution_time: 30 I'm looking for the file to be converted into a blob, it works perfectly fine for files less than 1mb, but doesn't even run the mysql query above that. Any Ideas anyone? include("../../connect.php"); # these settings should help set_time_limit(0); # going in as a blob from now on $stamp = mktime(); $safename = $_FILES['Filedata']['tmp_name']; $filename = $_FILES['Filedata']['name']; $size = $_FILES['Filedata']['size']; $type = $_FILES['Filedata']['type']; $fk = $_REQUEST['fk']; $sqlname = $stamp . "-" . $_FILES['Filedata']['name']; # open and code in $fp = fopen($safename, 'r'); $content = fread($fp, filesize($safename)); $content = addslashes($content); fclose($fp); $insertS = "INSERT INTO $tableb (pal, afield, bfield, cfield, dfield, efield, ffield, ablob) VALUES ('6', '$fk', '$filename', '$size', '$type', '$width', '$height', '$content')"; $insertQ = mysql_query($insertS); print "1"; I need to process a large CSV file (40 MB - 300,000 rows). While I have been working with smaller files my existing code is not able to work with large files. All I need to do is - read a particular column from file and then count total number of rows and add all the values from column. My exisitng piece of code imports whole CSV file into an array (a class is used) and then using 'ForEach' loop, reads the required column and values into another array. Once the data is in this array i can simply sum or count it. While this served me well for smaller files, i am not able to use this approach to read a larger php file. I have already increased the memory allocated to php and max_execution_time but the script just keeps on running I am no php expert but usualy get around with trial and error.......your thoughts and help will be greatly appreciated Exisiting code: Once data has been processed by initial class (Class used is freely available and known as 'parsecsv', available at http://code.google.com/p/parsecsv-for-php/) After calling the class and processing the csv file: ?php ini_set('max_execution_time', 3000); $init = array(0); //Initialize a dummy array, which hold value '0' foreach ($csv->data as $key => $col): //Get value from array, 'Data' is an array processed by class and holds csv data $ColValue = $col[SALARY']; //retrieves the column you want { $SAL= $col['SALARY']; //Column that you want to process from csv array_push ($init, $SAL); // Push value into dummy array created above echo "<pre>"; } endforeach; $total_rows = (Count($init) -1); //Count total number of value, '-1' to remove the first initilaized value in array echo "Total # of rows: ". $total_rows . "\n"; echo "Total Sum: ". array_sum($init) . "\n"; ?> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |