Jump to content

VTS

Members
  • Posts

    72
  • Joined

  • Last visited

    Never

Everything posted by VTS

  1. I just found out what it is doing....instead of having one field in $part, it has the whole line. I guess I need to go a little further with my exploding now and use it to seperate the fields. When I used echo on $part right after I used trim() on it, I get a whole line in it. I am about to go and try this now and see how it works.
  2. $rows has "211" in it. I don't think I have been this confused about something with php in about 4 months now lol. Any other ideas?
  3. Still no output....boy I am really starting to feel like a major noob with php now lol.
  4. Let me add one more thing. Each line has 4 values in it. In this line: "1 23 23.90 10" 1, 23, 23.90, and 10 are all seperate fields so I need to read them in seperately. I tried this: $file = "c:\\data.txt"; if(!file_exists($file)){ echo "File does not exist"; } $handle = fopen($file, "r"); $contents = fread($handle, filesize($file)); fclose($handle); $row = explode("\n", $contents); $rows = count($row); $i = 0; while($i < $rows-1){ $parts = explode('"', $row[$i]); unset($numbers); $numbers = array(); foreach($parts as $part) { $part = trim($part); if(is_numeric($part)) { array_push($numbers, $part); } } $store = array_pop($numbers); $a = array_pop($numbers); $b = array_pop($numbers); $c = array_pop($numbers); echo "</br> $store $a $b $c </br>"; $i++; } but it doesnt seem to work. I am just using an echo statement so I can see that it is working properly before I try inserting any data into the database. I probably just overlooked something stupid like I usually do. Any ideas on why its not working?
  5. Thanks, I will try that out now and see how it works.
  6. Well I do not need the " marks entered in my database. Those marks are generated by a program that I do not have access to. I guess I will try using the explode function. thanks for the help, VTS
  7. The problem that I am having is finding a way to read data into a database from a textfile that is set up like this: "1 23 23.90 10" Each line begins and ends with the " mark. I have read data from text files before, but they just had the "\n" at the end of the line. What do I do when it has a " mark at the beginning and ending of each line? Thanks in advance, VTS
  8. Thanks a bunch!  That will work just fine  ;D
  9. Is there a way in php to use something smaller than seconds?  I am currently using 'YmdHis' and I need to use something smaller than seconds in there.  Any help would be greatly appreciated.
  10. I still haven't figured it out...hopefully someone knows what I am doing wrong here.
  11. Anyone have any ideas?
  12. I understand what that statement is saying.  What I meant by I don't know what to do with this is that I am stuck and don't know what to do since it did not work.  Thanks for all the help.  I really appreciate it. 
  13. Well I tried that too and still no dice.  I really don't have any idea what to do with this.  The reason I didn't want to use the for statement is because I need to loop store by store one at a time and not just show them all on one page together.  When I use a for or while statment, I cannot get it to just show one store at a time.  Rather, it shows them all on the page.  My end goal with this code is to be able to have a page where a user is shown the store number and the fields that need to be input for that paticular store and when they hit the submit button, it stores the data in the datebase and then show the fields that need to be input for the next store and so on.  Thanks for the quick replies!!
  14. Still didn't work.  I need it to work in an if statement so that I can put some more code in there to display an input page that will cycle one store at a time which is controlled by hitting a submit button.  When I use a for statement like that, it just displays it 5 times.  But it still didn't display the store number.  Thanks for the help though.  Any other ideas?
  15. Ok, I have changed that line and now it is not printing anything for it.  I also changed another line.  I got rid of the mysql_fetch_array() for $sql10 because I want to be able to choose the store number from the store table.  Can anyone tell me what I am doing wrong?  Here is the new code: [code] $sql = "SELECT COUNT(*) num           FROM store           WHERE store_open_closed = 'o' "; $result = run_sql($sql) or die(mysql_error()); $storesql = "SELECT store_id                   FROM store                   WHERE store_open_closed = 'o'                   ORDER BY store_id"; $sql10 = run_sql($storesql) or die(mysql_error()); $stores = mysql_fetch_array($result); $x =0; if($x < $stores['num']){     $storenbr = array_slice($sql10,$x,1);     echo "store #: ".$storenbr[0]; } [/code]
  16. Ahhhh.  Ok thanks alot!!
  17. What I was trying to do was use array_slice to pick a store id and store it into a variable so I can display it.  When I used it like this, I got an array returned instead of a single value.  If you are wondering why I don't just use a while statement, it is because this is part of a page that is going to be displayed for one store at a time and is controlled by a submit button.  If you have problems understanding what I am trying to do just let me know and I will try to clarify.  By the way, run_sql() is a function I set up to use anytime I want to run a sql query if you were wondering.  Here is the code I am using: [code] $sql = "SELECT COUNT(*) num           FROM store           WHERE store_open_closed = 'o'"; $result = run_sql($sql) or die(mysql_error()); $storesql = "SELECT store_id                   FROM store                   WHERE store_open_closed = 'o'                   ORDER BY store_id"; $sql10 = run_sql($storesql) or die(mysql_error()); $sql11 = mysql_fetch_array($sql10); $stores = mysql_fetch_array($result); $x =0; if($x < $stores['num']){     $storenbr = array_slice($sql11,$x,1);     echo "store #: ".$storenbr; } [/code]
  18. Well the problem was that one source will have wage data and the other source will have sales data and they will not always have the same departments.  For example, the wage data my contain departments 1, 2, 3, 4, and 5 while the sales data may contain departments 1, 2, 3, 6, and 7.  I was wondering how to go about inserting these into the datebase but I figured it out now.  I just made a new table containing all the the departments and their id numbers.  Then I used some sql and php to check and see what totals were missing and then if a total was missing, I just inserted zeroes into that row in the db.  After doing this, all of my departments were accounted for and then I could just use a simple update statement to put the sales data in.  Thanks for the posts guys!!
  19. I will try to lay this out the best that I can.  I have a table that has the date, sales, department id, operating hours, and operating wages.  I am getting the date, sales and department id from one place and then I am getting the operating hours and operating wages from another department.  The major problem that I am having is that the place where I am getting the hours and wages from has some departements that the sales won't have and then the sales will have some departments that the hours and wages wont....does this mean I just need to make another table to store sales in one and wages and hours in another?
  20. The sda table contains data by day and it will have data for more than just one week.  Data will get stored into it each day and I want to take this daily data and store it into another table by week so that I have a weekly total field stored.  I want the weekly total for each id.
  21. Ok, I will try to explain this as best as I can.  I have a table with data in it like this: sda_id    sda_amt   sda_date    1         23.45      2006-07-21    2         45.22      2006-07-21    1         23.90      2006-07-20    2         46.32      2006-07-20    1         29.09      2006-07-19    2         60.06      2006-07-19 and this goes on for a complete week and there are about 40 different total ids.  What I am trying to do with this take the totals for each id and get their sum for a week and then store this new week total in a different table.  This other table will have id, week_amt and date for the headings in it.  I don't really know where to start with this.  If I did not post enough info just let me know and I will try to get a little more detailed.  Thanks for any help in advance.
  22. Thanks alot for the quick reply!!
  23. I was wondering if there was a way to use PHP or HTML to do a page break.  Thanks in advance for any 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.