Page 22 - Open Soource Technologies 304.indd
P. 22

Web Technologies-I



                   Notes         The output of the above given example is shown in Figure 1.10.
                                                      Figure 1.10: Output of the Database Query






                                                           Movie          Year    Actor
                                                 Dr No                    1962  Sean Connery
                                                 From Russia With Love    1963  Sean Connery
                                                 Goldfinger               1964  Sean Connery
                                                 Thunderball              1965  Sean Connery
                                                 You Only Live Twice      1967  Sean Connery
                                                 On Her Majesty's Secret Service 1969  George Lazenby
                                                 Diamonds Are Forever     1971  Sean Connery
                                                 Live and Let Die         1973  Roger Moore
                                                 The man With The Golden Gun 1974  Roger Moore
                                                 The Spy Who Loved Me     1977  Roger Moore
                                                 Moonraker                1979  Roger Moore
                                                 For Your Eyes Only       1981 Roger Moore


                                 Database-provided dynamic content drives the news and e-commerce sites at the heart of the Web.

                                 1.4.4 Graphics
                                 With PHP, you can easily create and manipulate images using the GD extension. Example provides
                                 a text-entry field that lets the user specify the text for a button. It takes an empty button image
                                 file, and on it centres the text passed as the GET parameter “message”. The result is then sent
                                 back to the browser as a PNG image.
                                               Dynamic buttons

                                 <?
                                 php if (isset($_GET[‘message’]))

                                 {
                                 // load font and image, calculate width of text
                                 $font = ‘times’;
                                 $size = 12;

                                 $im = ImageCreateFromPNG(‘button.png’);
                                 $tsize = imagettfbbox($size,0,$font,$_GET[‘message’]); // center
                                 $dx = abs($tsize[2]-$tsize[0]);
                                 $dy = abs($tsize[5]-$tsize[3]);

                                 $x = ( imagesx($im) - $dx ) / 2;
                                 $y = ( imagesy($im) - $dy ) / 2 + $dy; // draw text
                                 $black = ImageColorAllocate($im,0,0,0);



        16                                LOVELY PROFESSIONAL UNIVERSITY
   17   18   19   20   21   22   23   24   25   26   27