Code to get the next value of autoincrement for a table being used by joomla
$query = "SELECT `AUTO_INCREMENT` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = '{$databaseName}' AND TABLE_NAME = CONCAT('{$prefix}','stride_data')";
$db->setQuery($query);
$db->query();
$NextId = $db->loadAssocList();
//echo $NextId[0][AUTO_INCREMENT];
This code takes an array from model and sorts it on two dimensions of the array.
$new_array = array();
foreach($this->items as $temp)
{
$new_array[] = array("id"=>$temp->id, "CoachName" => $temp->CoachName, "CoachEmail" => $temp->CoachEmail, "SkaterName"=>$temp->SkaterName, "SkaterScno"=>$temp->SkaterScno, "Test"=>$temp->Test, "Dance"=>$temp->Dance, "SheetName"=>$temp->SheetName, "Partner"=>$temp->Partner, "GoldChallenge"=>$temp->GoldChallenge, "ClubNumber"=>$temp->ClubNumber);
}
foreach($new_array as $key => $row)
{
$SheetName[$key] = $row['SheetName'];
$SkaterName[$key] = $row['SkaterName'];
}
array_multisort($SheetName, SORT_ASC, $new_array, $SkaterName, SORT_ASC, $new_array);
$sql = "SELECT `parameter`, `value` FROM `#__testday_configuration` ";
$db->setQuery($sql);
$db->query();
$results = $db->loadAssocList();
$config = array();
foreach($results as $result)
{
$config[$result[parameter]] = $result[value];
}
Now you can use $config['address'] to access the value assigned to address.
I wanted to use a a PHP include or require in a field in an RSForms Pro form. To do this properly, I needed the base URL of the site. Here's what worked to get the base URL and the rest of the include.
//<code>
require(preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']) . '/includes/testday.php');
$items=get_session_list();
return($items);
//</code>
In this case, I needed to find the id of an article that was in a blog view. To do this in blog.php, you'll find that there is already the following code:
$this->item = &$item;
which contains an array of all the article parameters and content. As a result if you put:
echo $this->item->id;
immediately after it, you get the id number of the article.
- PHP code for use in a Joomla template to set the background image to be the full_text image from the article or the image for the category
- Using the Full Text image as a Background image
- To retrieve the URL of the intro image in a Joomla article
- Problem with accented characters not showing up using PHP and MySQL