Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ticket printing from database via php?

Status
Not open for further replies.

NickyJay

Programmer
Sep 1, 2003
217
GB
Hiya,

Bit new to PHP but want to try and get an output from my database in the form of tickets for an event that is held in the db.
There will be a maximum of 50 tickets per event, and I need to display the event name and start time from the db on each so though of using posts i found here to generate adress labels??

anyone any opinions as to this being the right track? any advice is gratefully received as this is a whole new project for me :)

note: I have developed apps in Coldfusion before and the transition between the two is still confusing for me at the mo...

Thanks!

Nicola
 
Hi

Looking at Google define:ticket, its meaning quite varies. For me ticket means bus ticket. What means for you ?

Anyway, if you are thinking to a web based solution, I would say is not the best idea. For such task I would use a desktop application, either CLI or GUI, possible also written in PHP. In this case I would generate image ( with ImageMagick ) or PDF document ( with FPDF ) and I would send that to the printer.

Feherke.
 
Many thanks,

By ticket, i mean like a raffle ticket type of piece of paper that is presented at the event venue to acknowledge payment of a seat. All 50 of the tickets should have the same info from the one event printed on them, and be subsequently numbered.
Thanks
 
Hi

Got it. It think I would do it like this :
[ul]
[li]create an image with the general design, ticket.png[/li]
[li]with a PHP script[ul]
[li]load the ticket.png[/li]
[li]put the variable texts on the image in predefined positions[/li]
[li]save the image to ticket-serialnr.png[/li][/ul][/li]
[li]send the ticket-*.png files to the printer[/li]
[/ul]
So only the second step would be done with PHP, and that would be a CLI script.

Feherke.
 
Hiya,

thanks again, i will give this ago and post back how i get on :)
 
If your confident with images you could generate a barcode to check if the ticket is genuine. Of course that needs a reader and way to check that code is genuine.
As an alternative have you condiered using something like the mailmerge facility in Ms-Word to generate the output.
My appoligies for coming late to the debate but I'm a bit bored !
 
Hi

I needed abit of relaxation, so here is an example :
[ul]
[li]from this ticket base file[/li]
[li]this PHP script
Code:
[highlight silver]#!/usr/bin/php[/highlight]
<?php

$base=[i]'ticket.png'[/i];  [gray]// ticket base image[/gray]
$from=1;             [gray]// first ticket number[/gray]
$to=3;               [gray]// last ticket number[/gray]
$date=[i]'2009-06-03'[/i];  [gray]// event date[/gray]
$time=[i]'18:30'[/i];       [gray]// event time[/gray]

$black=[b]new[/b] ImagickPixel([i]'black'[/i]);

$draw=[b]new[/b] ImagickDraw();
$draw->setFont([i]'/usr/lib/X11/fonts/TTF/DejaVuLGCSansCondensed.ttf'[/i]);
$draw->setFontSize(18);
$draw->setStrokeColor($black);
$draw->setFillColor($black);

[b]for[/b] ($i=$from;$i<=$to;$i++) {
  $image=[b]new[/b] Imagick($base);
  $image->annotateImage($draw,115,26,0,sprintf([i]'%05d'[/i],$i));
  $image->annotateImage($draw,315,26,0,$i);
  $image->annotateImage($draw,115,186,0,$date);
  $image->annotateImage($draw,315,187,0,$time);
  file_put_contents([i]"ticket-$i.png"[/i],$image);
}

?>
[/li]
[li]creates completed ticket file[/li]
[/ul]
This is just an example. I have no idea what kind of information you need to add from the database.


Feherke.
 
if you are using windows, php can print directly.
otherwise you will need to use cli to write to the printer socket.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top