|
|
|
| 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 : |
18400 |
| 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" ;
?>
|
|
| bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, 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 | | | Logs hits to any page which includes it. Automatically utilises page access information left behind by PHP/FI2.0. Categories : Databases, PHP, mSQL, Databases | | | DB Connection Function with error handling and email failure notices Categories : PHP, MySQL, Errors and Logging, Databases, Errors and Logging | | | database,php,mysql,demo,example,php3,training,tutorial,codes,code Categories : Databases, MySQL, PHP, PHP Options and Info | | | Automatically printing the contents of an sql table in MySQL. Categories : MySQL, PHP, HTML and PHP, Databases | | | Displaying records of database in more than one page (paging) Categories : Databases, MySQL, PHP | | | MySQL Class to ease Database connectivity Categories : MySQL, PHP Classes, Databases, PHP | | | This class splits the results of the query into multiple pages like what the search engine does. Categories : PHP Classes, PHP, MySQL, Databases | | | A Simple sign up script with PHP and JavaScript validations. Categories : PHP, Java Script, MySQL, Databases | | | I`d like to use the mysql_fetch_row function along with a "randomizer"
function that would give me a random result from a mySQL table. Categories : General SQL, MySQL, PHP, Databases | | | Download manager - A PHP script for adding a download page to any site.It also enables you track the no. of downloads. Categories : PHP, Content Management, Filesystem, Databases, MySQL | | | Create and restore backup of MySQL databases Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs | | | How can i Preload a 'SELECT MULTIPLE'? Categories : HTML and PHP, PHP, MySQL, Databases | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | |
| |
| |
|