Jump to content

searls03

Members
  • Posts

    907
  • Joined

  • Last visited

Everything posted by searls03

  1. searls03

    fpdf

    please let me know if that doesn't make sense......I am not good a t descripbing through text. haha
  2. searls03

    fpdf

    Ok. What I am trying to do is run the code that makes the cells serveral times......so that in my database all the rows that meet the date specs will display. currently it is only displaying one row instead of all the rows. Here is the updated code: if($_POST['submit']){ $startdate=$_POST['startdate']; $enddate=$_POST['enddate']; $sql = mysql_query("SELECT * FROM transactions where date between '$startdate' and '$enddate' "); while($row = mysql_fetch_array($sql)){ $date = $row["date"]; $product = $row["product"]; $month = $row["month"]; $day = $row["day"]; $year = $row["year"]; $category = $row["category"]; $academy = $row["academy"]; $price = $row["price"]; $priceunit = $row["priceunit"]; $quantity = $row["quantity"]; } // Query member data from the database and ready it for display require('fpdf.php'); class PDF extends FPDF { function EAN13($x=1, $y, $barcode, $h=16, $w=.35) { $this->Barcode(13,5,$barcode,$h,$w,13); } function UPC_A($x, $y, $barcode, $h=16, $w=.35) { $this->Barcode($x,$y,$barcode,$h,$w,12); } function GetCheckDigit($barcode) { //Compute the check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; $r=$sum%10; if($r>0) $r=10-$r; return $r; } function TestCheckDigit($barcode) { //Test validity of check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; return ($sum+$barcode[12])%10==0; } function Barcode($x, $y, $barcode, $h, $w, $len) { //Padding $barcode=str_pad($barcode,$len-1,'0',STR_PAD_LEFT); if($len==12) $barcode='0'.$barcode; //Add or control the check digit if(strlen($barcode)==12) $barcode.=$this->GetCheckDigit($barcode); elseif(!$this->TestCheckDigit($barcode)) $this->Error('Incorrect check digit'); //Convert digits to bars $codes=array( 'A'=>array( '0'=>'0001101','1'=>'0011001','2'=>'0010011','3'=>'0111101','4'=>'0100011', '5'=>'0110001','6'=>'0101111','7'=>'0111011','8'=>'0110111','9'=>'0001011'), 'B'=>array( '0'=>'0100111','1'=>'0110011','2'=>'0011011','3'=>'0100001','4'=>'0011101', '5'=>'0111001','6'=>'0000101','7'=>'0010001','8'=>'0001001','9'=>'0010111'), 'C'=>array( '0'=>'1110010','1'=>'1100110','2'=>'1101100','3'=>'1000010','4'=>'1011100', '5'=>'1001110','6'=>'1010000','7'=>'1000100','8'=>'1001000','9'=>'1110100') ); $parities=array( '0'=>array('A','A','A','A','A','A'), '1'=>array('A','A','B','A','B','B'), '2'=>array('A','A','B','B','A','B'), '3'=>array('A','A','B','B','B','A'), '4'=>array('A','B','A','A','B','B'), '5'=>array('A','B','B','A','A','B'), '6'=>array('A','B','B','B','A','A'), '7'=>array('A','B','A','B','A','B'), '8'=>array('A','B','A','B','B','A'), '9'=>array('A','B','B','A','B','A') ); $code='101'; $p=$parities[$barcode[0]]; for($i=1;$i<=6;$i++) $code.=$codes[$p[$i-1]][$barcode[$i]]; $code.='01010'; for($i=7;$i<=12;$i++) $code.=$codes['C'][$barcode[$i]]; $code.='101'; //Draw bars for($i=0;$i<strlen($code);$i++) { if($code[$i]=='1') $this->Rect($x+$i*$w,$y,$w,$h,'F'); } //Print text uder barcode $this->SetFont('Arial','B',12); $this->Text($x,$y+$h+11/$this->k,substr($barcode,-$len)); } //Instanciation of inherited class function Header() { global $name; global $date; global $product; global $month; global $day; global $year; global $academy; global $price; global $priceunit; global $category; global $quantity; // get the variable $name1 into the scope of this function //Logo //Arial bold 15 $this->SetFont('Arial','B',15); //Move to the right $this->Cell(70); //Title $this->Cell(0,0,'Please bring this to the next Scout Meeting',0,0,C); // Query member data from the database and ready it for display //Line break $this->Ln(20); $this->Cell(0,0,'',1,0); $this->Ln(20); $this->cell(50,10, 'Product:', 1,0); $this->cell(50,10, 'Category:', 1,0); $this->cell(50,10, 'Price:', 1,0); $this->Ln(10); $this->cell(50,10,$product, 'L,R',0); $this->cell(50,10, $category, 'L',0); $this->cell(50,10, $price, 'L,R',0); } //Page footer function Footer() { //Position at 1.5 cm from bottom $this->SetY(-15); //Arial italic 8 $this->SetFont('Arial','B',; //Page number $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); } } //Instanciation of inherited class $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Arial','B',12); $pdf->Output('ticket.pdf', 'I');} does this make more sense?
  3. searls03

    fpdf

    I need a little help with fpdf: <?php include_once("connect.php"); if($_POST['submit']){ $startdate=$_POST['startdate']; $enddate=$_POST['enddate']; $sql = mysql_query("SELECT * FROM transactions where date between '$startdate' and '$enddate' "); while($row = mysql_fetch_array($sql)){{ $date = $row["date"]; $product = $row["product"]; $month = $row["month"]; $day = $row["day"]; $year = $row["year"]; $category = $row["category"]; $academy = $row["academy"]; $price = $row["price"]; $priceunit = $row["priceunit"]; $quantity = $row["quantity"]; } // Query member data from the database and ready it for display require('fpdf.php'); class PDF extends FPDF { function EAN13($x=1, $y, $barcode, $h=16, $w=.35) { $this->Barcode(13,5,$barcode,$h,$w,13); } function UPC_A($x, $y, $barcode, $h=16, $w=.35) { $this->Barcode($x,$y,$barcode,$h,$w,12); } function GetCheckDigit($barcode) { //Compute the check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; $r=$sum%10; if($r>0) $r=10-$r; return $r; } function TestCheckDigit($barcode) { //Test validity of check digit $sum=0; for($i=1;$i<=11;$i+=2) $sum+=3*$barcode[$i]; for($i=0;$i<=10;$i+=2) $sum+=$barcode[$i]; return ($sum+$barcode[12])%10==0; } function Barcode($x, $y, $barcode, $h, $w, $len) { //Padding $barcode=str_pad($barcode,$len-1,'0',STR_PAD_LEFT); if($len==12) $barcode='0'.$barcode; //Add or control the check digit if(strlen($barcode)==12) $barcode.=$this->GetCheckDigit($barcode); elseif(!$this->TestCheckDigit($barcode)) $this->Error('Incorrect check digit'); //Convert digits to bars $codes=array( 'A'=>array( '0'=>'0001101','1'=>'0011001','2'=>'0010011','3'=>'0111101','4'=>'0100011', '5'=>'0110001','6'=>'0101111','7'=>'0111011','8'=>'0110111','9'=>'0001011'), 'B'=>array( '0'=>'0100111','1'=>'0110011','2'=>'0011011','3'=>'0100001','4'=>'0011101', '5'=>'0111001','6'=>'0000101','7'=>'0010001','8'=>'0001001','9'=>'0010111'), 'C'=>array( '0'=>'1110010','1'=>'1100110','2'=>'1101100','3'=>'1000010','4'=>'1011100', '5'=>'1001110','6'=>'1010000','7'=>'1000100','8'=>'1001000','9'=>'1110100') ); $parities=array( '0'=>array('A','A','A','A','A','A'), '1'=>array('A','A','B','A','B','B'), '2'=>array('A','A','B','B','A','B'), '3'=>array('A','A','B','B','B','A'), '4'=>array('A','B','A','A','B','B'), '5'=>array('A','B','B','A','A','B'), '6'=>array('A','B','B','B','A','A'), '7'=>array('A','B','A','B','A','B'), '8'=>array('A','B','A','B','B','A'), '9'=>array('A','B','B','A','B','A') ); $code='101'; $p=$parities[$barcode[0]]; for($i=1;$i<=6;$i++) $code.=$codes[$p[$i-1]][$barcode[$i]]; $code.='01010'; for($i=7;$i<=12;$i++) $code.=$codes['C'][$barcode[$i]]; $code.='101'; //Draw bars for($i=0;$i<strlen($code);$i++) { if($code[$i]=='1') $this->Rect($x+$i*$w,$y,$w,$h,'F'); } //Print text uder barcode $this->SetFont('Arial','B',12); $this->Text($x,$y+$h+11/$this->k,substr($barcode,-$len)); } //Instanciation of inherited class function Header() { global $name; global $date; global $product; global $month; global $day; global $year; global $academy; global $price; global $priceunit; global $category; global $quantity; // get the variable $name1 into the scope of this function //Logo //Arial bold 15 $this->SetFont('Arial','B',15); //Move to the right $this->Cell(70); //Title $this->Cell(0,0,'Please bring this to the next Scout Meeting',0,0,C); // Query member data from the database and ready it for display //Line break $this->Ln(20); $this->Cell(0,0,'',1,0); $this->Ln(20); $this->cell(50,10, 'Product:', 1,0); $this->cell(50,10, 'Category:', 1,0); $this->cell(50,10, 'Price:', 1,0); $this->Ln(10); $this->cell(50,10,$product, 'L,R',0); $this->cell(50,10, $category, 'L',0); $this->cell(50,10, $price, 'L,R',0); } //Page footer function Footer() { //Position at 1.5 cm from bottom $this->SetY(-15); //Arial italic 8 $this->SetFont('Arial','B',; //Page number $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C'); } }} //Instanciation of inherited class $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Arial','B',12); $pdf->Output('ticket.pdf', 'I');}?> Problem I am having is running the code through a loop. I need the products and such to run through the loop of querying the database so that all the entries in database meet the specs. please help:)
  4. If I were to put the arrays directly on the page after the form, and then use that page to submit, how would I make the page store the arrays for after a form on that page is submitted? so like store the arrays so they don't get submitted right away to make sure the sale is confirmed before submitting?
  5. try this: <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#msgsending").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('postmsg.php', $("#msgsending").serialize(), function(data) { }); } }); }); </script> if this doesn't work, check the processing page.
  6. oh, and I am not really following with the counter part, I realize that that is why I am getting an error....
  7. here is error with that Warning: Invalid argument supplied for foreach() in /home/tkdpostk/public_html/collect.php on line 5
  8. but the thing is with like academy[], is if I put the submission piece right on the next page using the arrays, it submits fine, the problem is when I try to pass those to the next page......
  9. oh, here is the code that the form that submits the arrays come from: <form name="pay" class="pay" method="POST" action="collect.php"> <p> <?php if ($total == ""){$total = "0";} ?> <?php echo "$".$total.""; ?> <?php // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM cart where cart_id = ".$_SESSION['cart_id']." && product123 !=''"); while($row = mysql_fetch_array($sql)){ $product = $row["product123"]; $price1 = $row["price"]; $id = $row["product_id"]; $qty = $row["quantity"]; $month = date("F Y"); $day = date("d"); $year = date("Y"); $date = date("Y-m-d"); ?> <input name="product[]" type="hidden" value="<?php echo $product; ?>" /><input name="academy[]" type="hidden" value="<?php echo $academy; ?>" /><input name="month[]" type="hidden" value="<?php echo $month; ?>" /><input name="day[]" type="hidden" value="<?php echo $day; ?>" /><input name="year[]" type="hidden" value="<?php echo $year; ?>" /><input name="date[]" type="hidden" value="<?php echo $date; ?>" /><input name="price[]" type="hidden" value="<?php echo $price1; ?>" /><input name="id[]" type="hidden" value="<?php echo $id; ?>" /> <input name="qty[]" type="hidden" value="<?php echo $qty; ?>" /><input name="total" type="hidden" value="<?php echo $total; ?>" /> <?php } ?> <?php if ($total == " "){$total = "0";} ?><input type="submit" name="pay" id="pay" class="pay1" value="" /> </p> </form>
  10. so now it is always inserting two, one with proper record, the other blank....like picture shows. here is where sessions are set: <?php include_once("connect.php"); session_start(); foreach($_POST["product"] AS $key => $val) { $_SESSION['product'] = $val; $_SESSION['month'] = $_POST['month'][$key]; $_SESSION['day'] = $_POST['day'][$key]; $_SESSION['year'] = $_POST['year'][$key]; $_SESSION['date'] = $_POST['date'][$key]; $_SESSION['price'] = $_POST['price'][$key]; $_SESSION['qty'] = $_POST['qty'][$key]; $_SESSION['id'] = $_POST['id'][$key]; $_SESSION['total'] = $_POST['total'][$key]; $_SESSION['academy'] = $_POST['academy'][$key]; $_SESSION['priceunit'] = $price * $qty; } ?> and then the other is exactly what you gave me
  11. ok, that is exactly one insert. I had cleared the table and ran the query, that's what the result was.
  12. the picture shows exactly what it is doing. I want it to post all the products that the sessions are holding. yes there should be more than one if there is more than one present. it should look similar to product 1 price 1 product id1 ,etc product 2 price 2 product id2 ,etc and so forth. it shouldn't be doing what the picture show. does this make a bit more sense?
  13. currently it is doing exactly what the picture shows regardless of how many I try to insert.
  14. I know what they were saying. I am just going to have to make a different submission page, which i was hoping not to do, but oh well.
  15. array(12) { ["product"]=> string(7) "DVD:TKD" ["month"]=> string(13) "February 2012" ["day"]=> string(2) "05" ["year"]=> string(4) "2012" ["date"]=> string(10) "2012-02-05" ["price"]=> string(2) "69" ["qty"]=> string(1) "1" ["id"]=> string(1) "4" ["total"]=> string(1) "6" ["academy"]=> string(0) "" ["priceunit"]=> int(0) ["cart_id"]=> string(1) "5" } I guess it is doing something now that it wasn't before, idk why, but it is. I realize that didn't change the results, but it was only doing two records when I tried two before. this is strange.
  16. the picture shows the result: I posted both DVD:TKD and Sparring Package This code only let it insert the one instead of one and a blank. the original code posted the right one about 7 times then inserted the blank one..............it wasn't doin this before.
  17. it's not technically the submission code, it is the code that leads to the submission code without the page refrehing.....
  18. it inserts one record properly......so all the fields insert right for one record.....but after that, they are inserting blank records. I may also not have the code written properly,so if there is an error, please tell:)
  19. ok, how do I make it work with the submission code though?
  20. so I need to know how to make this drop down include hidden fields in it: <form id="myform1" method="POST"> <select onchange="document.getElementById('myform1').submit()"> <?php //start the table, and the row. // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM products"); while($row = mysql_fetch_array($sql)){ $product = $row["product"]; $id =$row["id"]; $price =$row["price"]; ?> <option><input type="text" name="hiddenField2" class="hiddenField2" value="<?php echo $id; ?>" /> <input type="text" name="hiddenField1" class="hiddenField1" value="<?php echo $price; ?>" /><?php echo $product; ?> </option> <?php // start a column } ?> </select> <noscript> <input type="submit" value="Go" id="Submit1" /> </noscript> </form> Kind of like is shown.......so that each option has an id. then I need it to submit to this code: <script type="text/javascript"> $(document).ready(function(){ $(".myform1").validate({ debug: false, submitHandler: function(form) { // do other stuff for a valid form $.post('process.php', $(".myform1").serialize(), function(data) { $("#price").load("index.php #price");$("#total").load("index.php #total"); }); } }); }); </script> . Can anyone help? I hope this makes sense????
  21. does anyone know how to fix this?
  22. sorry, that second to last one wasn't supposed to be here.....this is the code I meant to post in the third to last: $x = 1; // set $x for ($i=1; $i<=100; $i += 9) { $start = array ($i);} //columns will be started at each of these numbers for ($n=0; $n<=100; $n += 9) { $end = array($n);}
  23. what I need is for a loop to run to make tabbed pannels according to categories. then I need the buttons to be put into the correct tab based on the category it falls under. then a subcategory tabs inside the other tabs for products that have that specific sub category. here is what I sorta made....it doesn't work though.... <div id="TabbedPanels1" class="TabbedPanels"> <ul class="TabbedPanelsTabGroup"><?php $sql = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($sql)){ $category = $row["category"]; $sub =$row["subcategory"]; ?> <li class="TabbedPanelsTab" tabindex="0"><?php echo $category; ?></li> <div class="TabbedPanelsContentGroup"> <div class="TabbedPanelsContent"> <?php // set layout vars $x = 1; // set $x $start = array ('1', '10', '19', '28', '37', '46', '55', '64', '73', '82', '91', '100', '109', '118', '127', '135'); //columns will be started at each of these numbers $end = array( '9', '18', '27', '36', '45', '54', '63', '72', '81', '90', '99','108','117', '126' ); // set numbers to end columns at ?> <?php echo '<table border="1px" cellpadding="0px" cellspacing="0px" ><tr height=\'50px\'>'; //start the table, and the row. // Query member data from the database and ready it for display $sql = mysql_query("SELECT * FROM products where category=".$category.""); while($row = mysql_fetch_array($sql)){ $product = $row["product"]; $id =$row["id"]; $price =$row["price"]; if (in_array($x, $start)) { // if x equals a number in the start array echo '<td width="100">'; // start a column } ?> <?php $sql = mysql_query("SELECT * FROM categories"); while($row = mysql_fetch_array($sql)){ $category = $row["category"]; $sub =$row["subcategory"]; ?> <?php } ?> <div id="products"> <form action="" method="POST" name="myform<?php echo $id; ?>" class="myform<?php echo $id; ?>"> <input type="hidden" name="hiddenField" class="hiddenField" value="<?php echo $product; ?>" /> <input type="hidden" name="hiddenField2" class="hiddenField2" value="<?php echo $id; ?>" /> <input type="hidden" name="hiddenField1" class="hiddenField1" value="<?php echo $price; ?>" /> <input type="submit" name="submit" class="submit" value="<?php echo $product; ?>" style="background-color:lightgreen; height:50px; padding: 0px; margin:0px; width:100px;"> </form> </div> <?php if (!in_array($x, $end)){ // if $x equals anything OTHER than 9, 18, etc - put in a line break } else { // else if it DOES equal 9, 18 ,etc end the column echo '</td>'; } $x ++; // increase x to keep count } // while loop ends //now outside of the loop, $x = $x - 1; //subtract the last $X++ so you know exactly how many buttons were added if (!in_array($x, $end)){ // if $x equals anything OTHER than 9, 18, etc - end the column as it wouldn't have ended itself echo '</td>'; } echo '</tr></table>'; // close the row and table ?><?php } ?> </div> </ul> </div> any help is greatly appreciated.
×
×
  • 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.