Configure HTML/JavaScript

Thursday, April 28, 2011

Function to get next Database ID

the bellow function will give you the next auto increament id of your database primary key.

function getNextID($field_id){
$db =& JFactory::getDBO();
$sql = "SELECT max(id) FROM jos_table WHERE field_name=$name";
$acl_num = $db->loadResult();
return ($acl_num + 1);
return 0;

in reference to:

"Some time we need to see some string type data of different rows in comma separated or other separated in a single field. for this type of implementation mysql have a function GROUP_CONCAT(field_value) . we can add GROUP BY cluse to get comma separated values in different cases."
- Techinical tips for practical uses (view on Google Sidewiki)