bonjour
je n'arrive pas a intégrer le code barre ( code 39) d'un article dans un tableau rempli par une lecture dans une bdd sql
j'arrive a remplir mon tableau
a mettre un code barre en même temps, a la positionner sur ma page un peu ou je veux mais comment les insérez dans mon tableau???
merci pour votre aide
code du tableau:
la fonction utilisé pour le code barre 39
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 <?Php $host_name = "localhost"; $database = "gestion_consommables"; // Change your database nae $username = "***"; // Your database user id $password = "****"; // Your password //////// Do not Edit below ///////// try { $dbo = new PDO('mysql:host='.$host_name.';dbname='.$database, $username, $password); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "<br/>"; die(); } $count="SELECT * FROM ref_epi "; $le_service=0; if (isset($_GET['service'])) { if ($_GET['service']==1){$count="SELECT * FROM ref_epi where service_1='1'";$le_service=1;} if ($_GET['service']==2){$count="SELECT * FROM ref_epi where service_2='1'";$le_service=2;} if ($_GET['service']==3){$count="SELECT * FROM ref_epi where service_3='1'";$le_service=3;} } require('code39.php'); $pdf = new PDF_Code39(); $pdf->AddPage(); $pdf->Code39(0,0,'CODE 39',1,10); // code barre a mettre dans une cellule $width_cell=array(20,100,5,5,5); $pdf->SetFont('Arial','B',7); $pdf->SetFillColor(193,229,252); // Background color of header // Header starts /// $pdf->Cell($width_cell[0],10,'REFERENCE',1,0,'C',true); // First header column $pdf->Cell($width_cell[1],10,'DESIGNATION',1,0,'L',true); // Second header column $pdf->Cell($width_cell[2],10,'CODE BARRE',1,1,'C',true); // Third header column //// header ends /////// $pdf->SetFont('Arial','',6); $pdf->SetFillColor(235,236,236); // Background color of header $fill=false; // to give alternate background fill color to rows /// each record is one row /// foreach ($dbo->query($count) as $row) { $pdf->Cell($width_cell[0],10,$row['reference'],1,0,'C',$fill); $pdf->Cell($width_cell[1],10,$row['designation'],1,0,'L',$fill); $pdf->Cell($width_cell[2],10,'e',1,1,'C',$fill); // mettre le code barre dans cette cellule $fill = !$fill; // to give alternate background fill color to rows } /// end of records /// $pdf->Output(); ?>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 <?php require('fpdf.php'); class PDF_Code39 extends FPDF { function Code39($xpos, $ypos, $code, $baseline=0.5, $height=5){ $wide = $baseline; $narrow = $baseline / 3 ; $gap = $narrow; $barChar['0'] = 'nnnwwnwnn'; $barChar['1'] = 'wnnwnnnnw'; $barChar['2'] = 'nnwwnnnnw'; $barChar['3'] = 'wnwwnnnnn'; $barChar['4'] = 'nnnwwnnnw'; $barChar['5'] = 'wnnwwnnnn'; $barChar['6'] = 'nnwwwnnnn'; $barChar['7'] = 'nnnwnnwnw'; $barChar['8'] = 'wnnwnnwnn'; $barChar['9'] = 'nnwwnnwnn'; $barChar['A'] = 'wnnnnwnnw'; $barChar['B'] = 'nnwnnwnnw'; $barChar['C'] = 'wnwnnwnnn'; $barChar['D'] = 'nnnnwwnnw'; $barChar['E'] = 'wnnnwwnnn'; $barChar['F'] = 'nnwnwwnnn'; $barChar['G'] = 'nnnnnwwnw'; $barChar['H'] = 'wnnnnwwnn'; $barChar['I'] = 'nnwnnwwnn'; $barChar['J'] = 'nnnnwwwnn'; $barChar['K'] = 'wnnnnnnww'; $barChar['L'] = 'nnwnnnnww'; $barChar['M'] = 'wnwnnnnwn'; $barChar['N'] = 'nnnnwnnww'; $barChar['O'] = 'wnnnwnnwn'; $barChar['P'] = 'nnwnwnnwn'; $barChar['Q'] = 'nnnnnnwww'; $barChar['R'] = 'wnnnnnwwn'; $barChar['S'] = 'nnwnnnwwn'; $barChar['T'] = 'nnnnwnwwn'; $barChar['U'] = 'wwnnnnnnw'; $barChar['V'] = 'nwwnnnnnw'; $barChar['W'] = 'wwwnnnnnn'; $barChar['X'] = 'nwnnwnnnw'; $barChar['Y'] = 'wwnnwnnnn'; $barChar['Z'] = 'nwwnwnnnn'; $barChar['-'] = 'nwnnnnwnw'; $barChar['.'] = 'wwnnnnwnn'; $barChar[' '] = 'nwwnnnwnn'; $barChar['*'] = 'nwnnwnwnn'; $barChar['$'] = 'nwnwnwnnn'; $barChar['/'] = 'nwnwnnnwn'; $barChar['+'] = 'nwnnnwnwn'; $barChar['%'] = 'nnnwnwnwn'; $this->SetFont('Arial','',10); $this->Text($xpos, $ypos + $height + 4, $code); $this->SetFillColor(0); $code = '*'.strtoupper($code).'*'; for($i=0; $i<strlen($code); $i++){ $char = $code[$i]; if(!isset($barChar[$char])){ $this->Error('Invalid character in barcode: '.$char); } $seq = $barChar[$char]; for($bar=0; $bar<9; $bar++){ if($seq[$bar] == 'n'){ $lineWidth = $narrow; }else{ $lineWidth = $wide; } if($bar % 2 == 0){ $this->Rect($xpos, $ypos, $lineWidth, $height, 'F'); } $xpos += $lineWidth; } $xpos += $gap; } } } ?>
Partager