Jump to content
xisto Community

signatureimage

Members
  • Content Count

    49
  • Joined

  • Last visited

Everything posted by signatureimage

  1. Dear geancanach, You might be wondering how a flash (.SWF) file obtains data from remote files. Flash can obtain external data from: * External Text Files (*.txt) * ASP/PHP Files (*.asp,*.php) * XML Files (*.xml) The values from these files has to be sent in a format understandable by Flash. Flash Actionscript has an XML object to obtain data from XML files. The Flash player loads variables and their values from any of the remote file into its memory and then uses them as required. How does Flash get external values? Variable-Value Format: 1. Flash needs to receive the variables and values in the format below: For a single variable: variable1=value1 2. Similarly for multiple variables it needs the same format, but separated by "&" in between them: &variable1=value1&variable2=value2&variable3=value3&variable4=value Note: The variable name should be understandable by you as to what it represents and shouldn't include spaces. Spaces should not be present between the "&" sign, the variable name, and the "=" sign. The values can have spaces. A. Loading Variables from External Text File into Flash 1. Flash can call any remote text file by using a command in the Actions Panel called loadVariables ('Load/Unload Movie' in Flash 5). 2. Select its 'Load Variables into location' option and give the URL of your file in the URL box provided. The command will now look like: loadVariables("your_file_URL.txt",""); Flash - 5 Load Variables ("your_file_URL.txt",""); 3. The values of the variables can be accessed from Flash with the help of the variable names specified in the external text file into any Dynamic text field in Flash. 4. Let the variable name of the Dynamic text field in Flash be called as 'dyn_txt'. The value of the variable can be obtained as follows: dyn_txt = variable1; 5. Obtaining variables and their values into the Flash interface from the text file should be done in a special format as mentioned below. This format can be remembered easily as the Variable-Value format Variable-Value Format (*.txt file) 1. Flash needs to receive the variables and values in the format below: For a single variable: variable1=value1 2. Similarly for multiple variables it needs the same format, but separated by "&" in between them: &variable1=value1&variable2=value2&variable3=value3&variable4=value B. Loading Variables from ASP/PHP Files into Flash 1. The ASP page interacts with the Database and gets the required data and sends the retrieved data to Flash. Read more.. 2. Flash can call any remote text file by using a command in the Actions Panel called loadVariables ('Load/Unload Movie'). 3. Select its 'Load Variables into location' option and give the URL of your file in the URL box provided. The command will now look like: loadVariables("your_file_URL.asp",""); (or)loadVariables("your_file_URL.php",""); Flash - 5 Load Variables ("your_file_URL.asp",""); (or)Load Variables ("your_file_URL.php",""); 4. The values of the variables can be accessed from Flash with the help of the variable names specified in the external text file into any Dynamic text field in Flash. Variable-Value Format (*.asp file) Flash needs to receive the variables and values in a similar format form the ASP file as shown below: response.write "&name=" & fldName & "&email=" & fldEmail & "&mess=" & fldMess & "&date=" & fldDate Variable-Value Format (*.php file) Flash needs to receive the variables and values in a similar format form the PHP file as shown below: echo "&name=$fldName&email=$fldEmail&mess=$fldMess&date=$fldDate C. Loading Data from XML Files into Flash 1. The Flash Actionscript object XML can be used to load the XML document returned by the server into Flash. 2. We first create an instance of the XML object and then load the XML document using the load command as shown below: getxmldata=new XML();getxmldata.load("xmldata.xml",""); 3. Create 4 Dynamic textboxes with variable names - xmldoc, node_name, topic, author and write the following code in the 3rd frame as given below: if (getxmldata.loaded){ var p = getxmldata.firstChild; xmldoc = getxmldata.childNodes; node_name=p.nodeName; topic=p.attributes.topic; author=p.attributes.author;} 4. The 'loaded' method is used to check for loading of the XML document, if it is loaded the values are retrieved from the XML document through the methods of XML object. 5. The firstChild method is used to reference the first child of the parent node, nodeName is used to retrieve the name of the XML Node. 6. The attributes if present, can be displayed using the attributes.attribute_name by specifying each attribute_name. More info on: macromedia More info on: smart webby
  2. Sorry,My WinRar 2.01 reports: CONSOLE File header brokenJohn.
  3. Dear nightfox, DSN servers do NOT participate themselves in the sending of email or the browsing of the web... When you type the name of a web site in the address bar of your browser, it is your browser that will first form a TCP/IP packet for the "Address Resolution Protocol" (ARP), requesting for the translation of the server name into a TCP/IP address. (Suppose you want http://www.somewhere-paris.com/en/ and you connect from yourisp.jp) These ARP packets will be routed in the following way: - on your own machine: the ARP cache that has been constructed since power-on - on your own machine: the hosts file + result: NOT FOUND - on the DNS server (yourisp.jp) of your Internet service provider (ISP): the ARP cache - on the DNS server of your ISP: the configuration file + result: NOT FOUND - on the DNS server for domain (jp) (the last word of your ISP's domain): the ARP cache - on the DNS server for domain (jp): the configuration file + result: info NOT FOUND in domain jp - on one of the top domain DNS servers: tha ARP cache - on one of the top domain DNS servers: the configuration file + result: info IS OVER THERE: - on the DNS server for domain (info) (the last word of your destination): the ARP cache - on the DNS server for domain (info): the configuration file + result: somewhere.info IS OVER THERE: - on the DNS server (somewhere.info) of your destination: the ARP cache - on the DNS server (somewhere.info) of your destination: the configuration file + result: http://www.somewhere-paris.com/en/ IS OVER HERE, AND HERE IS ITS TCP/IP ADDRESS The same is true for your e-mail client and your FTP client. They all have to first translate a server name into a TCP/IP address by means of the Address Resolution Protocol (ARP). You can inspect your local ARP cache with the ARP command-line utility of your OS. Once your browser has obtained the TCP/IP address of the web server, your browser will form a TCP/IP packet for the "HyperText Transfer Protocol" (HTTP), using the TCP/IP address that has been obtained. Similar action is true for your e-mail and FTP clients. The File Transfer Protocol (FTP) and the Simple Mail Transfer Protocol (SMTP) all work only with TCP/IP addresses, not with names. The DSN servers no longer participate in these TCP/IP packets. So, search the Internet for more explanations of the ARP....
  4. Dear H_E_H,The Subject of your post asks for an XML editor.The very best XML editor is - without doubt - XML SPY.The Body of your post asks for an XHTML editor.Any modern HTML editor will do.
  5. Dear ninjamunky, Some characters are indeed reserved for some special functions. Like the greater-than sign, the less-than sign and the pipe sign, and others. Therefore it is my habit to type all these texts into a separate file, like message1.txt And then, in the batch file, I execute: type message1.txt This has the very same result as various echo statements. The special batch characters pose no problem that way. And furthermore, I find it easier to maintain.
  6. I totally agree with Alpha six on this one: By the way, neither of them started with the name they have today! When the Netscape corporation invented a scripting possibility in their Netscape Navigator browser, they called it Livescript . When the Sun corporation invented a new programming language, they originally called it Oak . Sun renamed it as Java , and made much publicity around it. Specifications of the Java language, the JVM (Java Virtual Machine) and the Java API are community-maintained through the Sun-managed Java Community Process. Java was developed in 1991 by James Gosling and other Sun engineers, as part of the Green Project. As this Java became very well known, Netscape decided to try to cash in on this by renaming the language built into their browser to Javascript. Note that while some Java and Javascript code may appear similar, they are in fact two entirely different languages that serve completely different purposes. Not to be left behind, Microsoft's Internet Explorer was soon updated to support not one but two integrated languages. One was called vbscript and was based on the BASIC programming language and the other was called Jscript and was very similar to Javascript. In fact if you were very careful what commands you used you could write code that would be able to be processed as Javascript by Netscape Navigator and as Jscript by Internet Explorer. At that time, Netscape Navigator was by far the more popular browser, and so later versions of Microsoft's Internet Explorer implemented versions of Jscript that were more and more like Javascript. By the time that Microsoft's Internet Explorer became the dominant browser, Javascript had become the accepted standard for writing interactive processing to be run in the web browser. The importance of this scripting language was too great to leave its future development in the hands of the competing browser developers, and so in 1996 Javascript was handed over to an international standards body called ECMA, who then became responsible for the subsequent development of the language. As a result of this the language was officially renamed ECMAScript or ECMA-262 but most people still refer to it as Javascript.
  7. Dear simokrimo, Are you sure that you mean imysql libraries? I only know of the mysql libraries and the mysqli libraries. Both these quotes are from php.net The determing factor is the version of the MySQL engine that you have access to. Use <?php phpinfo(); ?> to find that out.
  8. Dear FearfullyMade, My two cents: You choice of C++, C#, and Java is a very good one. With your knowledge of C++, you will certainly have possibilities in the job market. Be it in client-server model programming or in GUI-based programming, even in the game industry. With your knowledge of C#, you will certainly have possibilities in the job market that is based on the Microsoft dotNET stable. Thinking in an Object-Oriented way will give you an edge over traditionnal programming. The same is true for JAVA. With your knowledge of JAVA, you will certainly have possibilities in the job market that is based on the JAVA stable. Be it in client-server model programming or in GUI-based programming, or even in the small world of embedded devices, like cell-phones, set-top boxes, the automotive industry, and the like. If you want to consider other languages, like COBOL, keep in mind that it is still around in many companies, mainly on the large central systems that were build in the seventies and the eighties, and that the craze in the nineties about COBOL programmers shortage was due to the year-2000-effect, that caused many COBOL programs to be reviewed and inspected for the Y2K bug. COBOL is a relatively easy language to learn. Applying the right program algorythms is the hard thing - as it is in any language. Furthermore, the companies that used to use COBOL are now switching mainly to JAVA, under the influence of IBM's choice for that language. Besides pure programming languages, please do not forget to try to become an ace in SQL. Were data-bases are concerned, you will soon find that your programming efforts will be interspersed with SQL statements. So, learn SQL, both the SQL Data Definition Language and the SQL Data Manipulation Language parts of it. Visit SQL.org. Concerning assembly language: there is no such thing as an assembly language ! There are as many assembly languages as there are processor types ! Assembly language for the 8086 - now Pentium - is radically different from the assembly language for the Power-PC and the assembly language for the ARM and the assembly language for the {fill in yourself}. So, really, concidering assembly language would be a thing when the job requires it. But, nevertheless, looking in one of those assembly languages is never a bad thing: you will have learned an approach to how to learn it! Many will say that you must learn JavaScript - or Perl - or PHP - or Python - or Ruby - or even Visual Basic. You must not. If you have the right programming algorythms in your fingers, then you can code in those languages with the reference manual on your knees - or the reference PDF in a window on the side of your screen. It is not the grammar of a language or the vocabulary of a language that is important. It are the algorythms. My two cents
  9. Dear jedipi, Yes, you can add a new column to an existing data-base table. First method: with the interactive phpMySql dialogs that you have on your control panel of asatahost.com Second method: with the SQL statement: ALTER TABLE ... May I suggest that you visit the mySQL website for the full explanation of this method. There, you will also find examples of how to let the data-base engine automatically generate the missing autoincrement values. The mySQL website is not the only source of valuable information, you should also visit SQL org. There you can find more general information and tutorials.
  10. Could it be that there is a mismatch with the VB6 that your have? There are several versions of VB6, like VB6 Professional and VB6 Enterprise, etc. Could it be that the msinet.ocx that you have downloaded is not the right one for the VB6 version that you have? Just an idea.... On my VB6 cd-rom, the msinet.cab is located in \Common\Tools\VB\Cabinets\
  11. Thanks for the information !Outlook Express also allows to connect to news servers - in order to read the news groups - and participate in it.Does anybody have a list of really good (-free-) newsreader proggies ?
  12. Dear jedipi, While deciding on the columns (=fields) of your data-base table, you should definitively use an extra column that has the data-base attribute autoincrement . This extra column will be used by the data-base engine as a counter, and the value of this column will be created by the data-base engine, everytime that a new row is inserted into the data-base table. Its value will auto-increment - as the name suggests. Most data-base designers use the name id for this extra column. If you want to obtain the last inserted row of the data-base table, all you have to to is request the row that has the highest value in that column. You ask the highest value with the MAX() data-base function, as in SELECT MAX(id) FROM myuserid_mydatabasetable;
  13. Just posting to check what my Signature Image PHP will generate.....
  14. Dear konedima, If you have never programmed before, and you want to experience what is required to deliver a running game, I propose that you take a look first at a very simple environment. One that does not immediately requires you to learn a computer language, but rather allows you to focus your attention on the LOGIC that is needed to produce a program, and also gives you a simple interface that you can use to design your game. Please visit the Peter Programming System at this site:Peter At first look, it may seem childish, but don't be fooled by the cute looks: programming a game is not simple, you will need logic, discipline, planning, and before all: AN IDEA ! So: look at the examples, and download PeterLite.
  15. One more FileZilla user here!Very powerfull to keep my Xisto.com web-site synchronous !Easy drag-drop actions.Does multiple transfers with the files in a transfer queue.Does simultaneous transfers - configurable.Recommended !
  16. Beste kratjeheineken, If you are hosted here at Xisto.com, you will have received the instructions on how to log on to your Cpanel . The Control Panel is the right place to create a database. These are the steps: 1. Surf to your control panel login. 2. Log on with your control panel username and password. 3. In the box Site Management Tools , select the icon MySQL Databases 4. Select a name for your database, and click Create MySQL database (Remember that the real name of your database will be prefixed with your cpanel username and an underscore - as mentioned in the Note below the dialog box.) 5. The Site Management Tools/MySQL Databases will then show you the necessary Connection Strings that you must use in your programs - be it Perl or PHP or Java. Print that page ! Your databse has been created, and now you can start creating the database tables inside your new database with another product: PHPMyadmin. A link to PHPMyadmin can already be found at the bottom of the Site Management Tools/MySQL Databases page. Or, on the home page of your control panel, in the box Site Management Tools , select the icon phpMyAdmin . Groeten van grote-bak-stella-artois,
  17. Dear jedipi, I coudn't help but notice in your example that you executed the shell commands two times: sh a.shsh a.sh >>log I suppose that the first execution was done to obtain the output on the console screen, and the second execution was done to obtain the output inside a file - what you call a log-file. The danger here is that in some cases, it could be possible that the result would not be exactly the same - for instance when a time-dependent value was produced by the shell command. There exists a shortcut to obtain the desired result by executing the bash script just once. sh a.sh | tee log The tee command is one of those odd little specialized Unix commands that come in handy at the strangest times. It both displays the command output on the screen, and stores it in a file. Use tee -a to append, instead of overwrite. So, for the second bash script, we will use: sh b.sh | tee -a log I hope that I have interpreted your question correctly, and that my proposal will help you.
  18. Dear kpa, I just inspected my Frontpage 98 cd-rom. The Image Composer setup files are 225 MB in size. Too big to e-mail you Perhaps searching on e-Bay for a second-hand Frontpage can help you...
  19. Dear nachgeist03, Before tackling the web-interface, let's first do a definition of the data-base structure that you need. You need a data-base table that contains a row for every fruit that you want to describe. The columns of that "fruits" data-base table would be: (1) id (identification) - type=integer - autoincrement (means that the data-base engine will generate a value for this field, automatically, when the row is inserted into the data-base table "fruits". (2) name (the fruit's name) - type=text (3) color_id - type-integer - this field will contain the identification number of the row in the "colors" data-base table that contains the information about fruit colors. Because we talked about a new data-base table, "colors", let's describe this tables. The columns of the "colors" data-base table would be: (1) id (identification) - type=integer - autoincrement (means that the data-base engine will generate a value for this field, automatically, when the row is inserted into the data-base table "colors". (2) name (the color's name) - type=text (3) description (the color's long description) - type=varchar We will need a web-dialog that allows us the enter the different colors, and their long description. The columns of the "recipes" data-base table would be: (1) id (identification) - type=integer - autoincrement (means that the data-base engine will generate a value for this field, automatically, when the row is inserted into the data-base table "recipes". (2) name (the recipe's name) - type=text (3) description (the recipe's long description) - type=varchar We will need a web-dialog that allows us the enter the different recipes, and their long description. And yet another data-base table is needed. This data-base table will be the link between the "fruits" and the "recipes" data-base tables. The columns of the "fruits_recipes" data-base table would be: (1) id (identification) - type=integer - autoincrement (means that the data-base engine will generate a value for this field, automatically, when the row is inserted into the data-base table "fruits_recipes". (2) fruit_id - type=integer - this field will contain the identification number of the row in the "fruits" data-base table that contains the information about fuits. (3) recipe_id - type=integer - this field will contain the identification number of the row in the "recipes" data-base table that contains the detailed information about fuit cooking recipes. Why did we separate our information into 4 data-base tables? This was done because of the rules of relational data-base design: when an information occurs more than once, it must be moved into a separate data-base table. This is know as "normalizing". Indeed, more than one fruit may be "red", and more than one fruit may be used in the same recipe, for instance "apple pie with raspberry topping". The "fruits" data-base table would be: id=1 - name=orange - color_id=4 id=2 - name=raspberry - color_id=6 id=3 - name=apple - color_id=5 id=4 - name=strawberry - color_id=6 The "colors" data-base table would be: id=1 - name=black - description=blabla... id=2 - name=white - description=blabla... id=3 - name=blue - description=blabla... id=4 - name=orange - description=blabla... id=5 - name=green - description=blabla... id=6 - name=red - description=blabla... The "recipes" data-base table would be: id=1 - name=Apple pie with raspberry topping - description=The recipe is as follows:....... The "fruits_recipes" data-base table would be: id=1 - fruit_id=2 - recipe_id=1 id=2 - fruit_id=3 - recipe_id=1 Now that the information is stored into separate tables, it has become very easy to use PHP to generate the drop-down boxes for the web-interface. We simply query the data-base table colors and obtain all valid colors, alfabetically. select id,name from colors order by name; (The same would be true for supplemental information, like the month that the fruit is available. Just create a separate data-base table, and insert a new column in the "fruits" data-base table.) The generated HTML would be: <SELECT NAME="mycolor"> <OPTION VALUE="1">black <OPTION VALUE="2">white <OPTION VALUE="3">blue <OPTION VALUE="4">orange <OPTION VALUE="5">green <OPTION VALUE="6">red </SELECT> And the PHP that would be called could do the following SQL: select name from fruits where color_id = $mycolor; This would result in all fruits with the color that the surfer had selected in the dropdown box. Moreover, the PHP could do the following SQL: select recipes.name, recipes.description from recipes,fruits,fruits_recipes where fruits.color_id = $mycolor and fruits_recipes.fruits_id = fruits.id and fruits_recipes.recipes_id = recipes.id; This would result in all recipes with fruits that have the color that the surfer had selected in the dropdown box. From here on, you can start designing your web-application...
  20. Dear Nqon, Please show the contents of $db_query_inn_n1 so that we know what the SQL statements are.
  21. Dear clovis and jcguy,The first thing to do is to check the contract that you have with your Internet Service Provider (ISP).Not every ISP allows you to set up a web-server on your home machine.And then there is the question of speed and bandwidth.If you experience a good speed while surfing yourself, that is an indication that you have a good DOWNLOAD speed. However, when you run a web-server, it's the other surfers that are downloading from you. That means that your are UPLOADING... And the upload speed may well be many times slower than the download speed.Concerning bandwith, again check the contract that you have with your ISP. Because you are uploading, check the monthly maximum amount of data that you are allowed to UPLOAD...When you are considering to do some web-development, I strongly recommend to install a package like XAMP or EasyPHP. For the simple reason that it is easier to test your web-development locally, on your own local web-server. And after the tests, you can upload your error-free web-site to a professionally operated web-host, like Xisto.com.... That's what I do.
  22. Let's hope that 360 is not a registered trademark, otherwise Microsoft could be in trouble. The type designation 360 was previously used by IBM for its large mainframe computers. (from the Computer History web-site )
  23. After reviewing my post, I found out that the original post was truncated. I will continue here, and restart with the sample # 14: And one more particularity of the PDF file, is the possibility to add "notes". The PHP PDF function PDF_add_note(); will be used. When the Adobe Acrobat Reader presents the PDF file to your surfer, he/she will have the possibility to open the note by double-clicking on the little note icon, placed somewhere in the text of the PDF page. Here is the complete code: <?php$mypdf = PDF_new();PDF_open_file($mypdf, "");PDF_set_info($mypdf, "Creator", "gen14.php");PDF_set_info($mypdf, "Author", "John");PDF_set_info($mypdf, "Title", "Prototype (PHP)");PDF_set_info($mypdf, "Subject", "Sample");PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "When we look more closely at this way of working,", 50, 750);PDF_add_note($mypdf, 245, 660, 550, 770, "Yes, what is going to happen here? We are not used to work that way, and now this statement stares at us ! ", "What do you mean, WORK ?", "note", 0);PDF_show_xy($mypdf, "we can clearly see the more open side of this project.", 50, 730);PDF_end_page($mypdf);PDF_close($mypdf);$mybuf = PDF_get_buffer($mypdf);$mylen = strlen($mybuf);header("Content-type: application/pdf");header("Content-Length: $mylen");header("Content-Disposition: inline; filename=gen14.pdf");print $mybuf;PDF_delete($mypdf);?>- Save this code as a new text file, let's name it gen14.php.- Upload it to your web site. - Browse to your gen14.php file on your web site. - Check the results. And how about a PDF file with links? Well, the PDF format was in use BEFORE the global proliferation of the Internet and the World Wide Web. Linking was already provided for in a PDF file. The Adobe Acrobat Reader will happily jump to a PDF page when the user clicks on a PDF link. Let's add some links. Let's create a "Table Of Contents" page at the beginning of our PDF file. How is it done? - Draw the text lines that will function as Table Of Contents text. - Draw some rectangles around these text lines, as a visual clue that it are links, and add a link towards other PDF pages to the surface area delimited by the rectangles. Sample: Draw the text lines of the Table Of Contents PDF page: PDF_show_xy($mypdf, "First page", 150, 670);PDF_show_xy($mypdf, "Second page", 150, 655);PDF_show_xy($mypdf, "Third page", 150, 640);PDF_show_xy($mypdf, "Fourth page", 150, 625);PDF_show_xy($mypdf, "Fifth page", 150, 610);PDF_show_xy($mypdf, "Sixth page", 150, 595);PDF_show_xy($mypdf, "Seventh page", 150, 580); Sample: Add a link to the other PDF pages by drawing light-blue dashed rectangles: PDF_set_border_style($mypdf, "dashed", 1);PDF_set_border_color($mypdf, 0.8, 0.8, 1);PDF_set_border_dash($mypdf, 3, 1);PDF_add_locallink($mypdf, 140, 670-3, 225, 670+9, 2, "retain");PDF_add_locallink($mypdf, 140, 655-3, 225, 655+9, 3, "retain");PDF_add_locallink($mypdf, 140, 640-3, 225, 640+9, 4, "retain");PDF_add_locallink($mypdf, 140, 625-3, 225, 625+9, 5, "retain");PDF_add_locallink($mypdf, 140, 610-3, 225, 610+9, 6, "retain");PDF_add_locallink($mypdf, 140, 595-3, 225, 595+9, 7, "retain");PDF_add_locallink($mypdf, 140, 580-3, 225, 580+9, 8, "retain"); Here is the complete code: <?php$mypdf = PDF_new();PDF_open_file($mypdf, "");PDF_set_info($mypdf, "Creator", "gen15.php");PDF_set_info($mypdf, "Author", "John");PDF_set_info($mypdf, "Title", "Prototype (PHP)");PDF_set_info($mypdf, "Subject", "Sample");PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 20);PDF_show_xy($mypdf, "Table of contents", 50, 700);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "First page", 150, 670);PDF_show_xy($mypdf, "Second page", 150, 655);PDF_show_xy($mypdf, "Third page", 150, 640);PDF_show_xy($mypdf, "Fourth page", 150, 625);PDF_show_xy($mypdf, "Fifth page", 150, 610);PDF_show_xy($mypdf, "Sixth page", 150, 595);PDF_show_xy($mypdf, "Seventh page", 150, 580);PDF_set_border_style($mypdf, "dashed", 1);PDF_set_border_color($mypdf, 0.8, 0.8, 1);PDF_set_border_dash($mypdf, 3, 1);PDF_add_locallink($mypdf, 140, 670-3, 225, 670+9, 2, "retain");PDF_add_locallink($mypdf, 140, 655-3, 225, 655+9, 3, "retain");PDF_add_locallink($mypdf, 140, 640-3, 225, 640+9, 4, "retain");PDF_add_locallink($mypdf, 140, 625-3, 225, 625+9, 5, "retain");PDF_add_locallink($mypdf, 140, 610-3, 225, 610+9, 6, "retain");PDF_add_locallink($mypdf, 140, 595-3, 225, 595+9, 7, "retain");PDF_add_locallink($mypdf, 140, 580-3, 225, 580+9, 8, "retain");PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page one", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page two", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page three", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page four", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page five", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page six", 50, 800);PDF_end_page($mypdf);PDF_begin_page($mypdf, 595, 842);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Page seven", 50, 800);PDF_end_page($mypdf);PDF_close($mypdf);$mybuf = PDF_get_buffer($mypdf);$mylen = strlen($mybuf);header("Content-type: application/pdf");header("Content-Length: $mylen");header("Content-Disposition: inline; filename=gen15.pdf");print $mybuf;PDF_delete($mypdf);?>- Save this code as a new text file, let's name it gen15.php.- Upload it to your web site. - Browse to your gen15.php file on your web site. - Check the results. So, we now have learned enough basic PDF writing stuff to finally make the web application we were interested in in the first place: - Accept some data from our surfer, via a html form. - Run a PHP script that interprets this data, and generates a unique PDF - on-the-fly. This is the scheme: - We present a html form (form16.html) - The surfers enters some data, and submits the form. - The form action calls a PHP script (gen16.php) - The PHP script interprets the data, entered by the surfer. - The PHP script generates a PDF file and sends it - via http - to the surfer's browser. - The surfer is impressed ! We will ask the surfer to enter a series of numbers, separated by commas. Let's say 5 numbers or so. We will then generate a PDF file with a colored pie-chart, based on these numbers. Cool ! Part One: The html form. Here is the complete code: <html><head><title>pdf by php</title><style>body {font-family:verdana,arial;font-size:12pt;}p {font-family:verdana,arial;font-size:12pt;}input {font-family:verdana,arial;font-size:12pt;}table {font-family:verdana,arial;font-size:12pt;}tr {font-family:verdana,arial;font-size:12pt;}td {font-family:verdana,arial;font-size:12pt;background-color:#eef;}th {font-family:verdana,arial;font-size:12pt;background-color:#ddf;font-weight:bolder;}a {color:#039;}h1 {font-family:verdana,arial;font-size:24pt;color:#039;background-color:#ffc;border:6px solid #ccb;margin:0px 30px 0px 30px;padding:6px 6px 8px 6px;font-weight:bolder;}</style></head><body><h1 align="center">generate a PDF, based on values from a html form.</h1><br><form action="gen16.php" method="post"><table border="1" cellpadding="6" cellspacing="0" align="center"><tr><th colspan=2>give the numerical values, separated by commas</th></tr><tr><td align="right"> ===></td><td><input type="text" name="data"></td></tr><tr><th colspan=2><input name="submit" type="submit" value="generate a pie chart in PDF with PHP"></th></tr></table></form></body></html>- Save this code as a new text file, let's name it form16.html.- Upload it to your web site. - Browse to your form16.html file on your web site. - Check the results. Part Two: The PHP script. Here is the complete code: <?php$mypdf = PDF_new();PDF_open_file($mypdf, "");PDF_set_info($mypdf, "Creator", "gen07.php");PDF_set_info($mypdf, "Author", "John");PDF_set_info($mypdf, "Title", "Prototype (PHP)");PDF_set_info($mypdf, "Subject", "Sample");PDF_set_info($mypdf, "Keywords", "PHP PDF PDFlib");PDF_begin_page($mypdf, 595, 842);$myfont = PDF_findfont($mypdf, "Times-Roman", "host", 0);PDF_setfont($mypdf, $myfont, 10);PDF_show_xy($mypdf, "Pie chart:", 450, 765);$mydata = $_POST['data'];$myslices = explode(",", $mydata);PDF_show_xy($mypdf, $mydata, 50, 765);$mysum = 0;$mydegrees = Array();$mydiameter = 250;$myradius = $mydiameter / 2;$mycolours = array(array(0.7, 0.7, 0.7),array( 0, 0, 1),array( 0, 1, 0),array( 1, 0, 0),array( 1, 1, 0),array( 0, 1, 1),array( 1, 0, 1),array( 0, 0, 0.5),array( 0, 0.5, 0),array(0.5, 0, 0),array( 0, 0.5, 0.5),array(0.5, 0.5, 0),array(0.5, 0, 0.5),);$mysum = array_sum($myslices);for ($y=0; $y<=sizeof($myslices); $y++) { $mydegrees[$y] = $myslices[$y] / $mysum * 360; PDF_setfont($mypdf, $myfont, 6); PDF_show_xy($mypdf, $mydegrees[$y], 50, 300 - (10 * $y));}PDF_setcolor($mypdf, "stroke", "rgb", 0.50, 0.50, 0.50);PDF_moveto($mypdf, 250, 600);PDF_lineto($mypdf, 350, 600);PDF_stroke($mypdf);$mylastangle = 0;for ($z=0; $z<sizeof($myslices); $z++){ PDF_setcolor($mypdf, "fill", "rgb", $mycolours[$z] [0], $mycolours[$z] [1], $mycolours[$z] [2]); $myendx = round(250 + ($myradius * cos($mylastangle * pi() / 180) ) ); $myendy = round(600 + ($myradius * sin($mylastangle * pi() / 180) ) ); PDF_moveto($mypdf, 250, 600); PDF_lineto($mypdf, $myendx, $myendy); PDF_arc($mypdf, 250, 600, $myradius, $mylastangle, ($mylastangle + $mydegrees[$z]) ); $mylastangle = $mylastangle + $mydegrees[$z]; PDF_fill_stroke($mypdf);}PDF_setcolor($mypdf, "stroke", "rgb", 0.00, 0.00, 0.00);PDF_circle($mypdf, 250, 600, $myradius);PDF_stroke($mypdf);PDF_end_page($mypdf);PDF_close($mypdf);$mybuf = PDF_get_buffer($mypdf);$mylen = strlen($mybuf);header("Content-type: application/pdf");header("Content-Length: $mylen");header("Content-Disposition: inline; filename=gen07.pdf");print $mybuf;PDF_delete($mypdf);?>- Save this code as a new text file, let's name it gen16.php.- Upload it to your web site. - Browse to your form16.html file on your web site. - Enter some numbers, separated by commas. - Check the results. - Show off to your relatives. - Get the credits for it. - Give John a Reputation point !
  24. # What's Ruby Ruby is the interpreted scripting language for quick and easy object-oriented programming. It has many features to process text files and to do system management tasks (as in Perl). It is simple, straight-forward, extensible, and portable. This was copied from the official site. I have tried the Ruby language, but have found that there is not much demand for Ruby programmers - outside of Japan, the homeland of Ruby. You need to think Object-Oriented - just like when programming in Java, which by the way is not a scripting language, but a full programming language.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.