Jump to content

jjf3

Members
  • Posts

    20
  • Joined

  • Last visited

jjf3's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hm, thanx I will definitely look into that.
  2. My apologies. 1. I thought that's what I was doing. I just told denno020 that if he wanted to create the webinvt.txt file himself he should just input about 20 elements of w/e. I only used "stuff" as an example in place of the sensitive data which is located in the webinvt. He seems to want the data in the txt file which is irrelevant to the problem. As I said before, I'm not sure if the environment that I get the data from will be able to communicate nicely with a database like that. It doesn't like outputting data. And I have no idea how the webinvt.txt was created in the first place. I will have to see from my end what else can be done with the limited capabilities of the system. However, I believe that the main problem has been solved. Thanks all for your help!
  3. OK increasing that count seems to have worked. I can get the datatable to load correctly, however, there is still a problem. It generates another table first which then feeds into the datatable after a couple of seconds. The datatable should just load up without having to do that, I would think. This I'm guess is a problem with the way the PHP is set up.
  4. IDK, I think that's just the way the table was set up. I inherited this project a couple of months ago. This was created three years ago and nobody quite knows how it works, so it's up to me to figure it out. That's why I was hired! So that being said, You don't need what's in the txt file, and anyway as I said before, that info is confidential. I cannot give it out, but it shouldn't matter what you put in the txt file. We get this information from a program that simulates a unix environment. I think the only output they have available is text. All of this information is taken from that program. What I don't know is the capabilities of that environment, and if it can even handle a database like that. I'm just giving you the background of our setup here. You probably won't be able to help out much here. I'm going to try increasing the row count by 6000 and see if that works.Seeing that we don't even have 6000 items it should eliminate that <tr>
  5. OK I figured it out! It's a mixture of the PHP and the HTML The HTML produces an extra <tr> after every ten rows. This obviously displaces the other rows inside the datatable. How would I go about eliminating this output? See this code: if($i==10) { $tmp = '<tr>'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } inside the rest of the PHP code: $fp=fopen("csv/inventory4.html",'w'); $write=fputs($fp,$html_body,strlen($html_body)); $i=0; $content = file("webinvt.txt"); foreach($content as $line) { $l=csv_split($line); if(!strstr($l[11],"SET")) { if($i==10) { $tmp = '<tr>'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } $onhand = (int)$l[15]; $committed = (int)$l[16]; $avail = $onhand - $committed; $wcdate = substr($l[23],4); $eastdate = substr($l[19],4); if(strstr($l[1],"DISC")) { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>'; } else { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr> '; } $write=fputs($fp,$html_body,strlen($html_body)); $i++; } } $html_body=' </tbody> </table> </div> </body> </html>'; $write=fputs($fp,$html_body,strlen($html_body)); fclose($fp); ?> Look for the second <tr> at the end of this HTML code: <tr> <td>other</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>other</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>other</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>other</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>other</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr><tr><tr> <td>more stuff</td> * * * ETC ETC
  6. So it works perfect locally with only the HTML, something within my PHP is messing it up! I don't think the document ready function works on the PHP file, but the PHP file re-writes the HTML every two hours. I'm thinking if there is a way to place the function on the HTML page without it being rewritten, then that would solve everything. Though I'm not certain. I'm not sure what I did to get the 8 rows to appear in the data table at first, but on the site, I haven't been able to re-create the features again. All the HTML is in the right spot. Although I do have a question about this last bit: Does this look right to you? $write=fputs($fp,$html_body,strlen($html_body)); $i++; } } $html_body=' </tbody> </table> </div> </body> </html>'; $write=fputs($fp,$html_body,strlen($html_body)); fclose($fp); ?>
  7. thanks I'll work on it tomorrow and yes I have 20 elements on a line. They are seperated by , and "". So it would look like, "stuff", "stuff" etc...
  8. Quite right, I forgot to add the </head> into the code on here. On the site it's there. Right before: <body id="dt_example">. Are you saying I should move the </head> to before the logo? I cannot attach the webinvt.txt. That is confidential information. However, you can make a txt file with "stuff," X20 on one row and multiply that by 5000 rows to get a general idea of what is going on in there. How would I be able to convert this to a database without messing up current operations and php scripts?
  9. Ok, i got that to work, partially. I got to put 8 rows of data in a table, but none of the rest appeared and the drop down and next buttons did not work. It only registered 8 entries. Datatables uses css classes for each row. I have options of: class="odd gradeA" class="even gradeA" class="even gradeC" class="gradeA" For Datatables how should I go about alternating between these in PHP? Take a look at the source code for the datatables example on their website for an example of what I am talking about. Also I had the datatable working but after I changed something I cannot get it back again. The features have since disappeared. HTML Output currently: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>CSV Contents</title> <link rel="stylesheet" type="text/css" href="/css/demo_page.css" /> <link rel="stylesheet" type="text/css" href="/css/demo_table.css" /> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script src="/js/jquery.js"></script> <script src="/js/jquery.dataTables.nightly.js"></script> <script src="/js/makedatatablesworkfunction.js"></script> <div class="img-with-text"> <img src="/csv/image002.png" alt="sometext" /> <p>"WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on November 5, 2013, 6:15 pm </h1> </div> </head> <body id="dt_example"> <div id="container"> <h1>Check Inventory Here</h1> <table cellpadding="0" cellspacing="0" border="0" class="display" id="inventory" width="100%"> <thead> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </thead> <tfoot> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </tfoot> </thead> <tbody> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> . . . . . . . . . . . . . * 50000 more rows of stuff! </tr> </tbody> </table> </div> </body> </html> And Here is the PHP: I use '; to escape after the first <tbody> so that I can include the following PHP code: '; $fp=fopen("csv/inventory4.html",'w'); $write=fputs($fp,$html_body,strlen($html_body)); $i=0; $content = file("webinvt.txt"); foreach($content as $line) { $l=csv_split($line); if(!strstr($l[11],"SET")) { if($i==10) { $tmp = '<tr >'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } $onhand = (int)$l[15]; $committed = (int)$l[16]; $avail = $onhand - $committed; $wcdate = substr($l[23],4); $eastdate = substr($l[19],4); if(strstr($l[1],"DISC")) { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>'; } else { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr> '; } $write=fputs($fp,$html_body,strlen($html_body)); $i++; } } $html_body=' </tbody> </table> </div> </body> </html>'; $write=fputs($fp,$html_body,strlen($html_body)); fclose($fp); ?> Where did I mess up here? It also loads slow because we have so much items, but I'm guessing this is a formatting issue and datatables should be able to handle 5000 items.
  10. OK Thank you! I will try adding it in the morning and let you know how it goes. After I clean up the HTML a bit I plan on, using the document ready function in a separate .js file. So then, all I would have to add is, right?: <script src="/js/makedatatablesworkfunction.js"></script> Also for the table. Would the code look something like this? <table id="inventory"> <thead> <tr> <th>Item No</th> ETC ETC Rest of HTML. Then in the makedatatablesworkfunction.js file change it from example to inventory like so: $(document).ready(function () { $('#inventory').dataTable(); });
  11. Thank you for your input, didn't catch that.
  12. $(document).ready(function () { $('#example').dataTable(); }); Thank you sooo much, it really is a life saver. I will try this out at work tomorrow. Funny as I was copying the text over to here, I caught a missing Div or two myself. Now I have a new way of error checking. The only question that I have remaining is, do you think the Divs are the reason for the document.ready function working not quite right? I use Sublime Text 2 for my editor and it always shows an error when I place in this piece of code: This goes on the php page. I have tried to end the $html_body variable by using ': but it doesn't even update then...
  13. I am soooo sorry I must of read your post wrong or something. I cannot give you the entire contents because there is confidential information in it, but I'll give you the jist of it. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>CSV Contents</title> <link rel="stylesheet" type="text/css" href="/css/demo_page.css" /> <link rel="stylesheet" type="text/css" href="/css/demo_table.css" /> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script src="/js/jquery.js"></script> <script src="/js/jquery.dataTables.nightly.js"></script> <div class="img-with-text"> <img src="/csv/image002.png" alt="sometext" /> <p>WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on November 5, 2013, 6:15 pm </h1> </div> </head> <body id="dt_example"> <div id="container"> <h1>Check Inventory Here</h1> <table> <thead> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </thead> <tbody> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> <tr> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> <td>stuff</td> </tr> . . . . . . . . . . . . . * 50000 more rows of stuff! </tr> </tbody> <tfoot> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </tfoot> </table> </body> </html>
  14. <?php set_time_limit(0); function csv_split($line,$delim=',',$removeQuotes=true) { #$line: the csv line to be split #$delim: the delimiter to split by #$removeQuotes: if this is false, the quotation marks won't be removed from the fields $fields = array(); $fldCount = 0; $inQuotes = false; for ($i = 0; $i < strlen($line); $i++) { if (!isset($fields[$fldCount])) $fields[$fldCount] = ""; $tmp = substr($line,$i,strlen($delim)); if ($tmp === $delim && !$inQuotes) { $fldCount++; $i += strlen($delim)-1; } else if ($fields[$fldCount] == "" && $line[$i] == '"' && !$inQuotes) { if (!$removeQuotes) $fields[$fldCount] .= $line[$i]; $inQuotes = true; } else if ($line[$i] == '"') { if ($line[$i+1] == '"') { $i++; $fields[$fldCount] .= $line[$i]; } else { if (!$removeQuotes) $fields[$fldCount] .= $line[$i]; $inQuotes = false; } } else { $fields[$fldCount] .= $line[$i]; } } return $fields; } $html_body = '<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" type="text/css" href="/css/demo_page.css"> <link rel="stylesheet" type="text/css" href="/css/demo_table.css"> <title>CSV Contents</title> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; } .style9 {font-size: 12px} .logo h1 {position: absolute; top: 5px; right: 5px; font-size:14px; } .logo img-with-text {float: left; left 5px; font-size:14px; .img-with-text {text-align: justify; width: 40%; height: 20%;} .img-with-text img {display: block; margin: 0 auto;} .search {margin : 0px;} --> </style> <script class="jsbin" src="http://datatables.net/download/build/jquery.dataTables.nightly.js"></script> <script type="text/javascript" language="javascript" src="/js/jquery.js"></script> <div class="img-with-text"> <img src="/image002.png" alt="sometext" /> <p>WC" is West Coast warehouse- please add approximately 2-3 weeks for the arrival to East Coast.<br><br> </p> </div> <div class="logo"> <br>Last Updated on '.date("F j, Y, g:i a",time()+3600).' </h1> </div> </head> <body id="dt_example"> <div id="container"> <h1> Check Inventory Here</h1> <table> <thead> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </thead> <tbody> '; $fp=fopen("csv/inventory4.html",'w'); $write=fputs($fp,$html_body,strlen($html_body)); $i=0; $content = file("webinvt.txt"); foreach($content as $line) { $l=csv_split($line); if(!strstr($l[11],"SET")) { if($i==10) { $tmp = '<tr>'; $write=fputs($fp,$tmp,strlen($tmp)); $i=0; } $onhand = (int)$l[15]; $committed = (int)$l[16]; $avail = $onhand - $committed; $wcdate = substr($l[23],4); $eastdate = substr($l[19],4); if(strstr($l[1],"DISC")) { $html_body ='<tr "> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr>'; } else { $html_body ='<tr> <td>'.$l[0].'</td> <td>'.$l[1].'</td> <td>'.$l[12].'</td> <td>'.$avail.'</td> <td>'.$l[17].'</td> <td>'.$l[18].'</td> <td>'.$eastdate.'</td> <td>'.$l[21].'</td> <td>'.$l[22].'</td> <td>'.$wcdate.'</td> </tr> '; } $write=fputs($fp,$html_body,strlen($html_body)); $i++; } } $html_body=' </tbody> <tfoot> <tr> <th>Item No</th> <th>Description</th> <th>Price</th> <th>Available</th> <th>Back Ordered</th> <th>On Order</th> <th>ETA WH</th> <th>WC On Hand</th> <th>WC On Ord</th> <th>WC Order Date</th> </tr> </tfoot> </table> </body> </html>'; $write=fputs($fp,$html_body,strlen($html_body)); fclose($fp); ?>
  15. http://forums.phpfreaks.com/topic/283504-input-csv-file-into-datatable/?do=findComment&comment=1456486 thank you sooo much. Its actually posted on another topic here. The link is above!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.