Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 14th, 2012  |  syntax: None  |  size: 1.85 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //While loop to print out lables and receive crates
  2.  
  3. $i=0;
  4. $number = $_POST['containers_received']; // just example
  5.  
  6. while ($i < $number)
  7. {
  8. $i++;
  9.  if($i == $number + 3)  break;  // break after 10 times
  10.  
  11. // $i++;
  12. // Do what you want to be repeated basically.
  13.  
  14.  
  15. $sql3="SELECT (crate_number + 1) as crate from crate_status ORDER BY crate_number DESC LIMIT 1";
  16. $result2 = mysql_query($sql3);
  17. // echo $sql;
  18.  
  19. // test for valid, grab data
  20.  
  21. $data = mysql_fetch_array($result2);
  22.  
  23. // html safe data
  24. $f_data = array_map('htmlspecialchars', $data);
  25.  
  26. $sql="INSERT INTO crate_status (crate_number, po_ID, qty, procedural_code)
  27. VALUES ('".$f_data['crate']."','".$_POST['po_ID']."','".$_POST['qty']."','2')";
  28.  
  29. // echo $sql;
  30.  
  31.  
  32. if (!mysql_query($sql,$con))
  33.   {
  34. die('Error: ' . mysql_error());
  35.   }
  36.  echo '<H1>Item Received</H1>';
  37.  
  38.  
  39.  
  40. if (!$con)
  41.   {
  42.   die('Could not connect: ' . mysql_error());
  43.   }
  44.  
  45.  
  46. // include "fire.php";
  47. echo '<H1>Inventory Updated</H1>';
  48.  
  49. $sql2='select crate_number from crate_status ORDER BY crate_number DESC LIMIT 1';
  50. $result = mysql_query($sql2);
  51.  
  52. // test for valid, grab data
  53. $data = mysql_fetch_array($result);
  54. $f_data2 = array_map('htmlspecialchars', $data);
  55.  
  56. // echo '<meta http-equiv="refresh" content="1;url=menu.php"/>';
  57. // echo '<meta http-equiv="refresh" content="1;url=printcrate.php"/>';
  58. $post_d = strpos($_POST['Name'], 'SLAB');
  59. sprintf($result2);
  60. if($post_d === false) {
  61. echo '<H1>Generating Container Label</H1>';
  62.  
  63. //      echo '<meta http-equiv="refresh" target="_index" content="1;url=bcprint.php?Name='.$_POST['Name'].'&crate_number='.$f_data2['crate_number'].'">';
  64.  
  65. } else {
  66.  
  67. echo '<H1>Generating Slab Label</H1>';
  68.  
  69. // echo '<meta http-equiv="refresh"content="1;url=bcsprint.php?Name='.$_POST['Name'].'&crate_number='.$f_data2['crate_number'].'&qty='.$_POST['qty'].'">';
  70.  
  71. }
  72. }
  73.  mysql_close($con);
  74.  
  75. ?>