|
|
|
| Title : |
Returns the last row from a select where multiple rows have been selected.
In this case it is used to determine the last number in an AUTO_INCREMENT column. I use it to create "ticket numbers" or anything that needs a unique ID in sequence. |
| Categories : |
mSQL, MySQL, Databases, PHP |
 Swift Griggs |
| Date : |
Jan 24th 1999 |
| Grade : |
2 of 5 (graded 3 times) |
| Viewed : |
11421 |
| File : |
No file for this code example. |
| Images : |
No Images for this code example. |
|
| Search : |
More code by Swift Griggs |
|
| Action : |
Grade This Code Example
|
|
| Tools : |
My Examples List |
|
|
|
|
|
|
I'm using this stupid technique, to set the numbering on a "trouble ticket"
system that I'm working on. I needed a way to number the tickets in sequence
and I didn't want to use a silly file or something like that. This will do
it pretty automatically.
You must create a table in your database that looks something like this.
create table sequence(
sequence INT NOT NULL AUTO_INCREMENT,
primary key(sequence)
);
Here is my code:
<?
mysql_connect("localhost","root","mystupidpassword");
mysql_select_db("test database");
mysql_query("insert into sequence VALUES(NULL)");
$query = mysql_query("select * from sequence");
$allrows = mysql_num_rows($query);
while($count < $allrows) {
$count++ ;
$row = mysql_fetch_array($query);
}
echo "$row[0] is the latest sequence number" ;
?>
|
|
| Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | This program allows you to upload an ODBC ressource - i.e. an MS-Access database to a MySQL server. Categories : Databases, MySQL, Complete Programs, PHP, Databases | | | bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | Cut your MySQL Connections to 1 line of code Categories : PHP, Beginner Guides, Databases, MySQL | | | simple script to send emails via a html-form to different users Categories : Email, MySQL, PHP, Databases | | | Point and Click Interface ala MS Access for creating SQL statements. Categories : MySQL, Complete Programs, General SQL, PHP, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs. Categories : Databases, PHP, MySQL, Complete Programs | | | Tropicalm Genetree Family (MySQL based family tree) Categories : PHP, Interfaces, Databases, MySQL, Complete Programs | | | Report Generation in Microsoft Access from a MYSQL database Categories : PHP, MySQL, Databases, MS Access | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Email a user with out exposing email address Categories : PHP, Databases, MySQL, Email | | | html split bar used to split in multiple pages a database result Categories : HTML and PHP, Databases, MySQL, PHP | | | A very simple and efficient split bar the B-Z bar , for mysql and php ...
Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms | | | http://phpMySearch.web4.hm - The phpMySearch search engine system is a completeworld wide web indexing and searching system for a small domain or intranet. Categories : Search Engines, PHP, Databases, MySQL | |
|
|
|