Home arrow PHP arrow Page 2 - Generating Contract Numbers for Online Licenses using PHP and MySQL

Inserting generated random numbers into a MySQL database - PHP

PHP and MySQL form a powerful combination of open source technology available to any web developer. One of the increasing trends in modern web development is the generation of online contracts. E-commerce websites selling services online need automated contract generation for faster delivery of services. This article will help you learn to use this technology so you can get it working on your web site.

TABLE OF CONTENTS:
  1. Generating Contract Numbers for Online Licenses using PHP and MySQL
  2. Inserting generated random numbers into a MySQL database
  3. Basic Form Code
  4. Generate Unique Contract numbers
By: Codex-M
Rating: starstarstarstarstar / 8
April 28, 2009

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Let’s go deeper and make an attempt to put the generated numbers into the MySQL database. To apply this to a realistic application, let’s write a PHP program that will allow us to enter names in the web form, and then have PHP assign a random number from 1 to 10 associated with that name, and then store the data in the MySQL database. In order to make this happen, we will create a database before we build the PHP script. To create a database using phpmyadmin, take the following steps:

Step 1: Log into phpmyadmin.

Step 2: Click the “database” link.

Step 3: In the create new database area, type: “randomnumber” (this is just an example; in your actual application you can select any name you like).

Step 4: Leave it set to “collation.”

Step 5: Now that we have a database named “randomnumber,” we will create a table. In the “Create new table on database randomnumber” area, let's type “randgenerated” (again, you can select any names you like).

Step 6: In the number of fields, type “2.” This is 2 because we will store two types of data; the first column will be the name and the second column will be the random number generated.

Step 6: In this stage, phpmyadmin will ask you to enter your desired field name and data types.

For illustration purposes we will use the field “name” and “random,” and then, using the default type varchar, we will use 30 characters for the name and two characters for the associated random number stored.

Leave everything else as it is, and then click save. MySQL will make a table using your defined variables. You can see the screen shot below; your table should be set up to look like that:

 



 
 
>>> More PHP Articles          >>> More By Codex-M
 

blog comments powered by Disqus
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 



© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap

Dev Shed Tutorial Topics: