Jump to content

johng

Members
  • Posts

    69
  • Joined

  • Last visited

    Never

About johng

  • Birthday 02/23/1983

Profile Information

  • Gender
    Male

johng's Achievements

Member

Member (2/5)

0

Reputation

  1. Well the problem comes when I add in the complexity of what it does before updating. I first have to go to a website where this information is held, and yes, this is the only way to do it, unfortunately. I don't have access to the database where it is being stored. Then I have to parse the source code for that website and look for specific lines of code to get the small amount of information I need. Then it has to update the row, and I have over 1000 rows in the table that need to get updated. It is a terrible system, but it is the simplest way of doing it for now. I think I am going to just divide it up into 30 groups, and just have it go off the date. It won't hit everything every month, but in two months, in theory it should go through every record. And if someone needs something immediately, they will let me know, and I'll do it manually, which is what they do now anyway. Anyway, Thanks for the help, I'll consider this topic "solved" because, for the most part, it is. Edit: 1000 records may not seem like much, but when you consider that you have to go to a different website (or part of the same website) and get the source code and parse it for each record, it becomes pretty cumbersome.
  2. I have a page that updates a table every workday. (these are standard updates, like if someone has moved, or has a different phone number or something.) It is too big of a query to run the entire table all at once, so it is split out. The split is grouped by the first letter of a first name field. Right now it is broken up into 5 parts, and each part has a group of letters (i.e. "a" to "d" is one group, "e" to "k" is the next, and so on. As you can see, these do not have an even number of letters, but that is because some letters have a lot more entries, and need to be in smaller groups.) The reason it is split out into 5 groups is that I can run one group on each workday (Monday through Friday), and I can have the PHP check what day of the week it is. (I use a case statement, the first case is for Monday, the second is for Tuesday, etc.) Maybe it will be easier if I add some code: <?php $today = date("w"); //This checks to see what day of the week it is and puts it as a numerical value. switch($today){ case 1: //This case runs on Mondays $criteria = " where fname between 'a%' and 'd%' OR fname like 'd%'"; break; case 2: //This case runs on Tuesdays $criteria = " where fname between 'e%' and 'k%' OR fname like 'k%'"; break; case 3: //This case runs on Wednesdays $criteria = " where fname between 'l%' and 'n%' OR fname like 'n%'"; break; case 4: //This case runs on Thursdays $criteria = " where fname between 'o%' and 'r%' OR fname like 'r%'"; break; case 5: //This case runs on Fridays $criteria = " where fname between 's%' and 'z%' OR fname like 'z%'"; break; ?> Now the table is getting too big, and I am going to have to change it so that it will go through the whole table in a month (about 20-21 work days) My problem is that I don't know how I would have the code divide the groups into 20 parts for the case statement. I need it to break out so that it will hit the next group on the next business day, so I can't just use the day of the month, because then on weekends, it will not update those groupings. I don't have to use the first letter of the first name, it was just easier to do that for now. I could potentially use an automatic row id, in which case it would be much easier to make even groupings, but that will not be too difficult. So if anyone can help me out with this, that would be great. Hopefully it isn't too confusing, and the code helped. If you need me to clarify something, please let me know. Thanks.
  3. Well, that looks like it would work, but way too complicated for what I want. I was hoping that there was just something simple, but it's not a big deal. Thanks for finding that for me, maybe I will get super ambitious someday and try to figure it out... maybe... Anyway, thanks again all for helping me out!
  4. Any idea on how to format the excel cells? (Like make them bold, or merge cells or anything like that?)
  5. Mjdamato, you are truely amazing. Thank you for a very creative (and very effective!) work around for my problem. It worked like a charm (after figuring out that I needed to change my code back!). So happy that it works now! Now all I have to do is make sure it is all still there for when I pull info from my db. Thanks again!!! EDIT: Also, thanks for everyone who gave input/ideas. That's what these forums are all about!!! Thanks all for sticking with me to help figure this out!
  6. When I use the code that was posted, I got a regular excel file (not csv) and it had four different values: This is what it looks like when you just look at the cells: 1.23457E+15 1.2345678901235E+15 1.23457E+15 1234567890123456 This is what is actually in the cells: 1234567890123500 1.2345678901235E+15 1234567890123460 1234567890123456 So what I am fighting is both excel (the second to bottom one is excel formatted) and also PHP (the first two are php formatted). The first one is put in as a number, the second is put in as text (so php actually formatted it like that and placed it in the cell with the 'E') The third one is a number, (which excel formatted, only holding 15 places), and the last one is text again, the only one that is exactly how it should be. The only problem with that one is that I can't get it to do that without putting quotes directly around the number itself, not a variable or anything else. ("1234567890123456") That's the trouble I'm having, because when I pull it in from a database, I can't manipulate the number directly like that.
  7. Basically what I'm using the $numbers for is to simulate pulling it from a sql database. That's why I have kept the $numbers just a number, not added anything to it. I'm figuring that I can put it into another variable, and mess with that variable, but I won't be able to do anything to the original number (like put quotes or anything around it). That's what's making this so difficult for me.
  8. I just have the code that mjdamato posted at the top of this page. I need to bring in some numbers from a database, but before I do that, I want to make sure that I can make php see them as the data type I want (text, rather than a number). I have account numbers that are 16 digits long, and with php as well as excel, they cut off at least one of the last digits. What I was trying to do with that code is to export it to excel, and keep all 16 digits. What I was working on (and still not succeeding) is passing the number (without the quotes) through another variable, so I could try manipulating a variable, instead of just manipulating the number. Example: <?php (string)$numbers = 1234567890123456; $longNumberAsNumber = $numbers; ?> and this: <?php $numbers = 1234567890123456; $longNumberAsNumber = "'".$numbers; ?> and this: <?php $numbers = 1234567890123456; $longNumberAsNumber = "$numbers"; ?> And none of them have worked.
  9. Unfortunately, neither of those methods worked when I tried them with this function. I'll keep trying things and update with my results.
  10. One more question. If I am getting the number from a variable, how would ensure it was stored as as text?
  11. I don't know what happened, but now that I try it again, it spits out an excel file. Thanks for your help!
  12. Is there anything I need to modify to be able to just test it, to see where everything is coming from? Basically what I want to do is just put that code into a site and have it output an excel sheet, then I will look at that sheet and figure out where it is getting each of the pieces of information so I can replace them with the info I need to give it. I want to do this so you don't have to walk me through what each piece of code actually does. Right now, after just putting it into a new php page, and it is just printing this on the page: I was wondering if you knew what I would need to do to get this functional. Is there something I'm missing? maybe an include or something? Thanks for all your help by the way! You guys (and gals) are all amazing!
  13. That would be my third favorite movie of all time, boondock saints.
  14. How would I go about inserting it into a premade template? This is the code that I'm working with to put it into the Excel sheet right now. $header1, $header2 and $data are all strings that have text in them, $header1 and $header2 are one line each, and $data can have many lines (it has a line return between the lines) and the lines are tab delimited (they have the "\t" between the fields, separating the columns <?php header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename=report.xls"); header("Pragma: no-cache"); header("Expires: 0"); print "$header1\n$header2\n$data"; ?> Right now I'm creating a new file, but I don't know how to just insert the data into a template.
  15. Unfortunately, settype() doesn't work. I think I will probably just have to go with the apostrophe in front of the number. But if you all want to keep thinking, I am open to other ideas and will try something else if it might work. Thanks for all of your help.
×
×
  • 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.