Jump to content

[SOLVED] CMS System Need Help


Lamez

Recommended Posts

 

How would I be able to pull the highest ID number from the database and add 1 to it?

 

example:

 

--ID-- --title-- --news--

1          wel..    welcome to the website

2          hi          this is an update

..        ..          ..

11        hello      look at this

 

so I would want to select the ID 11 and add 1 to it so it would become 12, and then I could insert it into the database.

 

Thanks Guys :D

 

Link to comment
https://forums.phpfreaks.com/topic/114176-solved-cms-system-need-help/
Share on other sites

is a database function built into them i use mysql myself. go into the property's of the table and set id or the one you want to go up to auto_increment and then when you add your line just leave id blank and the database will put the next highest number in there for you.

 

or when you build the table set it here is how i built a table i used.

 

CREATE TABLE `server_globals` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(65) NOT NULL default '',
  `value` varchar(65) NOT NULL default '?',
  PRIMARY KEY  (`id`),
  UNIQUE KEY `qname` (`name`,`value`)
) ENGINE=MyISAM AUTO_INCREMENT=1280 DEFAULT CHARSET=latin1;

 

see how i set id to auto_increment and even set a starting value

 

so UPDATE tablename SET `id` int(11) NOT NULL auto_increment

 

should work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

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.