Jump to content

pacchiee

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Everything posted by pacchiee

  1. Is there any PHP class/plugin available to set margin, page width, page height and other settings for a printer?
  2. Hello, I have a table with the following structure and entries: id|score1|score2|grade 1|90|100|A 2|75|89|B 3|60|74|C 4|40|59|D 5|0|39|E Now, given a score how can I fetch the grade? Example: Given score as 85, I should fetch 'B'. Or is that I need to change the structure of the table altogether? Am new to MySQL; please help. Thanks in Advance!
  3. Can you please add the number of days too? Something like this : 2 Years 4 Months 12 Days Thanks in Advance!
  4. Further, how to select data from this table by matching only date or month or year? For instance, lets assume $today = date('Y-m-d'); SELECT * FROM tableName WHERE product = 'foobar' AND MONTH(date) = MONTH($today) Is that correct?
  5. Oh! Okay, I will change it. It is in YYYY-MM-DD format.
  6. Hello, I have a table with three columns - id, product, date. id is unique + auto increment. Entries of many products go into the same table along with date. Now, I need to fetch the latest entry from this table for a given product based on date, which am not able to do. Please help. Thanks in Advance.
  7. Since everything else seems to be fine, assuming there is no password for the user root, try editing your Line 4 to mysql_connect ("localhost","root",""); If you have set a password for user root, it should be something like this mysql_connect ("localhost","root","password");
  8. Page1.php <?php session_start(); echo 'Session ID is '.session_id().'<br>'; echo '<a href="Page2.php">Go to Page 2</a>'; ?> Page2.php <?php session_start(); if (session_id()=''){ echo 'Session ID is empy??'; }else{ echo session_id(); } ?> That should solve the problem. Always session_start() should be at the top of anything else in a php file when using Sessions.
  9. Function to round the result to two decimal points: <?php function seventyFive($bag) { echo round($bag * .75,2); } ?> You can call the function like below: <?php seventyFive(2500.98); ?> Output will be 1875.74
  10. Can you please give an example how to use explode() and foreach() to get an ordered list as I mentioned above?
  11. Hello, I wanted to convert a string to an ordered list. Something like below: EX-1 $string = "a,b,c,d,e,f"; The above string should be listed as 1. a 2. b 3. c 4. d 5. e 6. f EX-2 $string = "a,b"; The above string should be listed as 1. a 2. b EX-3 $string = "a"; The output should be 1. a I thought of using list(), but the number of variables may differ in the string and don't know how to handle it. Please help. Thanks in Advance.
  12. Hello nbarone, Thanks so much for you help. I got it working with the above function. Cheers!
  13. Hello nbarone, Thanks. That function rounds an integer to the nearest specified SINGLE number. But I want to round an integer to its nearest 5 or 10 BOTH.
  14. Hello, I want to round off an integer to end with 5 or 0 with PHP. For example: 21.4 should be rounded to 20 23.8 should be rounded to 25 26.4 should be rounded to 25 28.1 should be rounded to 30 and so on.. Please help. Thanks in Advance.
  15. You mean to say that I should also remove the session cookie?
  16. I have used PHP Session to authenticate users to a panel. Since it is to be used offline in a single machine, after verifying the username and password combination, am storing the username in a session variable. Further, I thought if somehow this session variable is edited, the user should be logged out and used this code. if(isset($_SESSION['username'])) { mysql_connect('localhost','database_user','database_password') or die(mysql_error()); mysql_select_db('database_name') or die(mysql_error()); $result = mysql_query("SELECT * FROM table WHERE username = '$_SESSION[username]'") or die(mysql_error()); $num_rows = mysql_num_rows($result); mysql_close(); if($num_rows == "0") { session_destroy(); echo "<meta http-equiv=\"refresh\" content=\"0;url=login.php\">"; exit; } } If the number of rows fetched is zero, the user is taken to login page. But, the session data is not cleared. I want to clear all the session data, please check what is the reason for the session data not to be cleared. To my surprise, I use link 'login.php?out' for logging out and following code for logging out which works and clears all the session data. if(isset($_GET['out'])) { session_destroy(); echo "<meta http-equiv=\"refresh\" content=\"0;url=login.php\">"; exit; } I have no idea while the second works why not the first? Please help. Thanks in Advance.
  17. I followed printer_set_option() in the below manner <?php $handle = printer_open(); printer_set_option($handle, PRINTER_SCALE, 30); printer_write($handle, "Some Text To Print\nSome More Text"); printer_close($handle); ?> It did not work. I even tried this <?php $handle = printer_open(); printer_set_option($handle, PRINTER_PAPER_FORMAT, PRINTER_FORMAT_CUSTOM); printer_set_option($handle, PRINTER_PAPER_LENGTH, 63); printer_set_option($handle, PRINTER_PAPER_WIDTH, 84); printer_write($handle, "Some Text To Print\nSome More Text"); printer_close($handle); ?> This didn't work either. I don't know if there is something wrong in the above!!
  18. I just was wondering, if it was possible to set the page parameters to the printer with PHP before sending the printer_write() command?? Are there any possibilities of doing it?
  19. Sure, I will do a bit of homework on PHP SESSION and the procedure outlined by neil and revert back with issues. Thanks neil.johnson, flyhoney, and 947740 for your help. Meanwhile, if anyone has some other way to pursue this task, please do let me know.
  20. This seems to be a good idea. What I feel is, keep storing the print data in $_SESSION until it can cover a page length (say for example 40 lines). Once the data to be sent to the printer has reached a maximum length (say we fix it to some 40 lines), the print_write() should be executed. Since am new to PHP, I don't really know if this works and even don't know how to pursue this if at all it is right. Please help.
  21. Hello, I am trying to print a few lines of text using my default printer through PHP as below: <?php $handle = printer_open(); printer_write($handle, "Line1: Some Text Here\nLine2: Some More Text Here\nLine3: Some Other Text Here\nLine4: Some Text Here"); printer_close($handle); ?> This prints the 4 lines, no problem at all. But, after printing 4 lines, the page scrolls to leave the remaining page empty. Instead, what I want is the printer to stop at the 4th line after printing the 4 lines. Once I refresh the page or send another print command, it should continue printing from the 5th line onwards. This I have been trying to do since almost a month ago with no success. Can you please help? Thanks in Advance.
  22. Hello thebadbad, Your solution worked just perfect for me! Thanks everybody who took your time to guide me through. Cheers
  23. Practically speaking, yes! But the weighing machine is sending the output in that fashion. If it were to send the data only once, it should have looked like "+0002.189 Lt". But, it is sending the data to PHP continuously, so the same value has been repeated many number of times. Further, when I change the weight on the weighing machine and refresh the PHP page to read again, it is adding the new weight to the end of the previous output. So, I should be reading from the end of the string to get the recent weight. And the output data will be in the below format
×
×
  • 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.